Custom JCR (Jackrabbit) node property type

I want to use a constant enumfor the property value in jackrabbit. However, it Node.setProperty()accepts primitive types, Stringand Valueas types of property values.

I looked at the interface ValueFactory, but it also looks like it cannot help me.


In other words, I want to do this:

node.setProperty("name", Enum.Const);

not this:

node.setProperty("name", Enum.Const.toString());

Thanks in advance.

+3
source share
1 answer

There is no standard way to do what you want. The JCR API simply does not allow the storage of arbitrary Object values. The only valid property types in JCR 1.0 are:

  • STRING
  • BINARY
  • LONG
  • DOUBLE
  • DATE
  • BOOLEAN
  • NAME
  • PATH
  • REFERENCE

All of these property types are valid in JCR 2.0, but there are several new ones:

  • WEAKREFERENCE
  • URI
  • DECIMAL

, javax.jcr.ValueFactory , Value java.lang.Object.

:

  • STRING , 'toString()';
  • LONG enum ordinal() ' ;
  • BINARY BINARY

IMO, 1 . 2 , - , JCR-SQL JCR-SQL2. 3 , .

1 2 node. , , , node node, node, . , , ( STRING PATH), ( LONG, DOUBLE DATE), ( BINARY), node ( REFERENCE WEAKREFERENCE), ( NAME). , , .

, 1 2 , , . 1 STRING , . CND JCR 2.0:

[ex: foo] mixin
  - ex: bar (STRING) 'VALUE1', 'VALUE2', 'VALUE3'

2 ( ) LONG. :

[ex: foo] mixin
  - ex: bar (STRING) [0,3)

+9

Source: https://habr.com/ru/post/1766963/


All Articles