You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by tr...@apache.org on 2009/06/17 22:22:09 UTC
svn commit: r785777 [3/4] - in /jackrabbit/trunk:
jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/
jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/
jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/com...
Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java Wed Jun 17 20:21:54 2009
@@ -17,120 +17,112 @@
package org.apache.jackrabbit.spi.commons.nodetype.compact;
import java.io.Reader;
-import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
import javax.jcr.NamespaceException;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.ValueFormatException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeTypeDefinition;
+import javax.jcr.query.qom.QueryObjectModelConstants;
import javax.jcr.version.OnParentVersionAction;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueConstraint;
import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
import org.apache.jackrabbit.spi.commons.conversion.NameException;
import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
import org.apache.jackrabbit.spi.commons.name.NameConstants;
import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeDefinitionFactory;
import org.apache.jackrabbit.spi.commons.nodetype.compact.QNodeTypeDefinitionsBuilder.QNodeDefinitionBuilder;
import org.apache.jackrabbit.spi.commons.nodetype.compact.QNodeTypeDefinitionsBuilder.QNodeTypeDefinitionBuilder;
import org.apache.jackrabbit.spi.commons.nodetype.compact.QNodeTypeDefinitionsBuilder.QPropertyDefinitionBuilder;
+import org.apache.jackrabbit.spi.commons.query.qom.Operator;
import org.apache.jackrabbit.util.ISO9075;
/**
* CompactNodeTypeDefReader. Parses node type definitions written in the compact
- * node type definition format and returns a list of QNodeTypeDefinition objects that
- * can then be used to register node types.
+ * node type definition format and provides a list of QNodeTypeDefinition
+ * objects that can then be used to register node types.
+ *
* <p/>
* The EBNF grammar of the compact node type definition:<br>
* <pre>
- * cnd ::= ns_mapping* node_type_def+
- *
- * ns_mapping ::= "<" prefix "=" namespace ">"
- *
- * prefix ::= string
- *
- * namespace ::= string
- *
- * node_type_def ::= node_type_name [super_types] [options] {property_def | node_def}
- *
- * node_type_name ::= "[" string "]"
- *
- * super_types ::= ">" string_list
- *
- * options ::= orderable_opt | mixin_opt | orderable_opt mixin_opt | mixin_opt orderable_opt
- *
- * orderable_opt ::= "orderable" | "ord" | "o"
- *
- * mixin_opt ::= "mixin" | "mix" | "m"
- *
- * property_def ::= "-" property_name [property_type_decl] [default_values] [attributes] [value_constraints]
- *
- * property_name ::= string
- *
- * property_type_decl ::= "(" property_type ")"
- *
- * property_type ::= "STRING" | "String |"string" |
- * "BINARY" | "Binary" | "binary" |
- * "LONG" | "Long" | "long" |
- * "DOUBLE" | "Double" | "double" |
- * "BOOLEAN" | "Boolean" | "boolean" |
- * "DATE" | "Date" | "date" |
- * "NAME | "Name | "name |
- * "PATH" | "Path" | "path" |
- * "REFERENCE" | "Reference" | "reference" |
- * "UNDEFINED" | "Undefined" | "undefined" | "*"
- *
- *
- * default_values ::= "=" string_list
- *
- * value_constraints ::= "<" string_list
- *
- * node_def ::= "+" node_name [required_types] [default_type] [attributes]
- *
- * node_name ::= string
- *
- * required_types ::= "(" string_list ")"
- *
- * default_type ::= "=" string
- *
- * attributes ::= "primary" | "pri" | "!" |
- * "autocreated" | "aut" | "a" |
- * "mandatory" | "man" | "m" |
- * "protected" | "pro" | "p" |
- * "multiple" | "mul" | "*" |
- * "COPY" | "Copy" | "copy" |
- * "VERSION" | "Version" | "version" |
- * "INITIALIZE" | "Initialize" | "initialize" |
- * "COMPUTE" | "Compute" | "compute" |
- * "IGNORE" | "Ignore" | "ignore" |
- * "ABORT" | "Abort" | "abort"
- *
- * string_list ::= string {"," string}
- *
- * string ::= quoted_string | unquoted_string
- *
- * quoted_string :: = "'" unquoted_string "'"
- *
- * unquoted_string ::= [A-Za-z0-9:_]+
+ * Cnd ::= {NamespaceMapping | NodeTypeDef}
+ * NamespaceMapping ::= '<' Prefix '=' Uri '>'
+ * Prefix ::= String
+ * Uri ::= String
+ * NodeTypeDef ::= NodeTypeName [Supertypes]
+ * [NodeTypeAttribute {NodeTypeAttribute}]
+ * {PropertyDef | ChildNodeDef}
+ * NodeTypeName ::= '[' String ']'
+ * Supertypes ::= '>' (StringList | '?')
+ * NodeTypeAttribute ::= Orderable | Mixin | Abstract | Query |
+ * PrimaryItem
+ * Orderable ::= ('orderable' | 'ord' | 'o') ['?']
+ * Mixin ::= ('mixin' | 'mix' | 'm') ['?']
+ * Abstract ::= ('abstract' | 'abs' | 'a') ['?']
+ * Query ::= ('noquery' | 'nq') | ('query' | 'q' )
+ * PrimaryItem ::= ('primaryitem'| '!')(String | '?')
+ * PropertyDef ::= PropertyName [PropertyType] [DefaultValues]
+ * [PropertyAttribute {PropertyAttribute}]
+ * [ValueConstraints]
+ * PropertyName ::= '-' String
+ * PropertyType ::= '(' ('STRING' | 'BINARY' | 'LONG' | 'DOUBLE' |
+ * 'BOOLEAN' | 'DATE' | 'NAME' | 'PATH' |
+ * 'REFERENCE' | 'WEAKREFERENCE' |
+ * 'DECIMAL' | 'URI' | 'UNDEFINED' | '*' |
+ * '?') ')'
+ * DefaultValues ::= '=' (StringList | '?')
+ * ValueConstraints ::= '<' (StringList | '?')
+ * ChildNodeDef ::= NodeName [RequiredTypes] [DefaultType]
+ * [NodeAttribute {NodeAttribute}]
+ * NodeName ::= '+' String
+ * RequiredTypes ::= '(' (StringList | '?') ')'
+ * DefaultType ::= '=' (String | '?')
+ * PropertyAttribute ::= Autocreated | Mandatory | Protected |
+ * Opv | Multiple | QueryOps | NoFullText |
+ * NoQueryOrder
+ * NodeAttribute ::= Autocreated | Mandatory | Protected |
+ * Opv | Sns
+ * Autocreated ::= ('autocreated' | 'aut' | 'a' )['?']
+ * Mandatory ::= ('mandatory' | 'man' | 'm') ['?']
+ * Protected ::= ('protected' | 'pro' | 'p') ['?']
+ * Opv ::= 'COPY' | 'VERSION' | 'INITIALIZE' | 'COMPUTE' |
+ * 'IGNORE' | 'ABORT' | ('OPV' '?')
+ * Multiple ::= ('multiple' | 'mul' | '*') ['?']
+ * QueryOps ::= ('queryops' | 'qop')
+ * (('''Operator {','Operator}''') | '?')
+ * Operator ::= '=' | '<>' | '<' | '<=' | '>' | '>=' | 'LIKE'
+ * NoFullText ::= ('nofulltext' | 'nof') ['?']
+ * NoQueryOrder ::= ('noqueryorder' | 'nqord') ['?']
+ * Sns ::= ('sns' | '*') ['?']
+ * StringList ::= String {',' String}
+ * String ::= QuotedString | UnquotedString
+ * QuotedString ::= SingleQuotedString | DoubleQuotedString
+ * SingleQuotedString ::= ''' UnquotedString '''
+ * DoubleQuotedString ::= '"' UnquotedString '"'
+ * UnquotedString ::= XmlChar {XmlChar}
+ * XmlChar ::= see ยค3.2.2 Local Names
* </pre>
*/
public class CompactNodeTypeDefReader {
/**
- * Empty array of value constraints
- */
- private final static String[] EMPTY_VALUE_CONSTRAINTS = new String[0];
-
- /**
* the list of parsed QNodeTypeDefinition
*/
- private final List nodeTypeDefs = new LinkedList();
+ private final List<QNodeTypeDefinition> nodeTypeDefs
+ = new LinkedList<QNodeTypeDefinition>();
/**
* the current namespace mapping
@@ -158,27 +150,63 @@
private final QNodeTypeDefinitionsBuilder builder;
/**
- * Creates a new CND reader.
- * @param r
- * @param systemId
- * @param builder
- * @throws ParseException
+ * Creates a new CND reader and parses the given stream it directly.
+ *
+ * @param r a reader to the CND
+ * @param systemId a informative id of the given stream
+ * @throws ParseException if an error occurs
+ */
+ public CompactNodeTypeDefReader(Reader r, String systemId)
+ throws ParseException {
+ this(r, systemId, new NamespaceMapping(), null);
+ }
+
+ /**
+ * Creates a new CND reader and parses the given stream it directly.
+ * If <code>builder</code> is <code>null</code> the reader uses the
+ * default {@link QNodeTypeDefinitionsBuilderImpl}.
+ *
+ * @param r a reader to the CND
+ * @param systemId a informative id of the given stream
+ * @param builder build for creating new definitions or <code>null</code>
+ * @throws ParseException if an error occurs
*/
- public CompactNodeTypeDefReader(Reader r, String systemId, QNodeTypeDefinitionsBuilder builder) throws ParseException {
+ public CompactNodeTypeDefReader(Reader r, String systemId,
+ QNodeTypeDefinitionsBuilder builder)
+ throws ParseException {
this(r, systemId, new NamespaceMapping(), builder);
}
+ /**
+ * Creates a new CND reader and parses the given stream it directly.
+ *
+ * @param r a reader to the CND
+ * @param systemId a informative id of the given stream
+ * @param mapping default namespace mapping to use
+ * @throws ParseException if an error occurs
+ */
+ public CompactNodeTypeDefReader(Reader r, String systemId, NamespaceMapping mapping)
+ throws ParseException {
+ this(r, systemId, mapping, null);
+ }
/**
- * Creates a new CND reader.
- * @param r
- * @param builder
- * @throws ParseException
+ * Creates a new CND reader and parses the given stream it directly.
+ * If <code>builder</code> is <code>null</code> the reader uses the
+ * default {@link QNodeTypeDefinitionsBuilderImpl}.
+ *
+ * @param r a reader to the CND
+ * @param systemId a informative id of the given stream
+ * @param mapping default namespace mapping to use
+ * @param builder build for creating new definitions
+ * @throws ParseException if an error occurs
*/
public CompactNodeTypeDefReader(Reader r, String systemId, NamespaceMapping mapping,
QNodeTypeDefinitionsBuilder builder) throws ParseException {
- this.builder = builder;
+ this.builder = builder == null
+ ? new QNodeTypeDefinitionsBuilderImpl()
+ : builder;
lexer = new Lexer(r, systemId);
this.nsMapping = mapping;
this.resolver = new DefaultNamePathResolver(nsMapping);
@@ -189,13 +217,27 @@
/**
* Returns the list of parsed QNodeTypeDefinition definitions.
*
- * @return a List of QNodeTypeDefinition objects
+ * @return a collection of QNodeTypeDefinition objects
*/
- public List getNodeTypeDefs() {
+ public List<QNodeTypeDefinition> getNodeTypeDefinitions() {
return nodeTypeDefs;
}
/**
+ * Convenience methdo that returns the list of parsed NodeTypeDefinition
+ * definitions, using the {@link NodeTypeDefinitionFactory}.
+ *
+ * @param session repository session used for converting the definitions.
+ * @return a collection of NodeTypeDefinition objects
+ * @throws RepositoryException if an error occurs
+ */
+ public List<NodeTypeDefinition> getNodeTypeDefinitions(Session session)
+ throws RepositoryException {
+ NodeTypeDefinitionFactory fac = new NodeTypeDefinitionFactory(session);
+ return fac.create(nodeTypeDefs);
+ }
+
+ /**
* Returns the namespace mapping.
*
* @return a NamespaceMapping object.
@@ -207,7 +249,7 @@
/**
* Parses the definition
*
- * @throws ParseException
+ * @throws ParseException if an error during parsing occurs
*/
private void parse() throws ParseException {
while (!currentTokenEquals(Lexer.EOF)) {
@@ -219,6 +261,8 @@
QNodeTypeDefinitionBuilder ntd = builder.newQNodeTypeDefinition();
ntd.setOrderableChildNodes(false);
ntd.setMixin(false);
+ ntd.setAbstract(false);
+ ntd.setQueryable(true);
ntd.setPrimaryItemName(null);
doNodeTypeName(ntd);
doSuperTypes(ntd);
@@ -233,8 +277,8 @@
/**
* processes the namespace declaration
*
- * @return
- * @throws ParseException
+ * @return <code>true</code> if a namespace was parsed
+ * @throws ParseException if an error during parsing occurs
*/
private boolean doNameSpace() throws ParseException {
if (!currentTokenEquals('<')) {
@@ -264,8 +308,8 @@
/**
* processes the nodetype name
*
- * @param ntd
- * @throws ParseException
+ * @param ntd nodetype definition builder
+ * @throws ParseException if an error during parsing occurs
*/
private void doNodeTypeName(QNodeTypeDefinitionBuilder ntd) throws ParseException {
if (!currentTokenEquals(Lexer.BEGIN_NODE_TYPE_NAME)) {
@@ -284,14 +328,11 @@
/**
* processes the superclasses
*
- * @param ntd
- * @throws ParseException
+ * @param ntd nodetype definition builder
+ * @throws ParseException if an error during parsing occurs
*/
private void doSuperTypes(QNodeTypeDefinitionBuilder ntd) throws ParseException {
- // a set would be nicer here, in case someone defines a supertype twice.
- // but due to issue [JCR-333], the resulting node type definition is
- // not symmetric anymore and the tests will fail.
- ArrayList supertypes = new ArrayList();
+ Set<Name> supertypes = new HashSet<Name>();
if (currentTokenEquals(Lexer.EXTENDS))
do {
nextToken();
@@ -299,29 +340,39 @@
nextToken();
} while (currentTokenEquals(Lexer.LIST_DELIMITER));
- ntd.setSupertypes((Name[]) supertypes.toArray(new Name[0]));
+ ntd.setSupertypes(supertypes.toArray(new Name[supertypes.size()]));
}
/**
* processes the options
*
- * @param ntd
- * @throws ParseException
+ * @param ntd nodetype definition builder
+ * @throws ParseException if an error during parsing occurs
*/
private void doOptions(QNodeTypeDefinitionBuilder ntd) throws ParseException {
- if (currentTokenEquals(Lexer.ORDERABLE)) {
- ntd.setOrderableChildNodes(true);
- nextToken();
- if (currentTokenEquals(Lexer.MIXIN)) {
- ntd.setMixin(true);
- nextToken();
- }
- } else if (currentTokenEquals(Lexer.MIXIN)) {
- ntd.setMixin(true);
- nextToken();
+ boolean hasOption = true;
+ while (hasOption) {
if (currentTokenEquals(Lexer.ORDERABLE)) {
+ nextToken();
ntd.setOrderableChildNodes(true);
+ } else if (currentTokenEquals(Lexer.MIXIN)) {
+ nextToken();
+ ntd.setMixin(true);
+ } else if (currentTokenEquals(Lexer.ABSTRACT)) {
nextToken();
+ ntd.setAbstract(true);
+ } else if (currentTokenEquals(Lexer.NOQUERY)) {
+ nextToken();
+ ntd.setQueryable(false);
+ } else if (currentTokenEquals(Lexer.QUERY)) {
+ nextToken();
+ ntd.setQueryable(true);
+ } else if (currentTokenEquals(Lexer.PRIMARYITEM)) {
+ nextToken();
+ ntd.setPrimaryItemName(toName(currentToken));
+ nextToken();
+ } else {
+ hasOption = false;
}
}
}
@@ -329,12 +380,12 @@
/**
* processes the item definitions
*
- * @param ntd
- * @throws ParseException
+ * @param ntd nodetype definition builder
+ * @throws ParseException if an error during parsing occurs
*/
private void doItemDefs(QNodeTypeDefinitionBuilder ntd) throws ParseException {
- List propertyDefinitions = new ArrayList();
- List nodeDefinitions = new ArrayList();
+ List<QPropertyDefinition> propertyDefinitions = new LinkedList<QPropertyDefinition>();
+ List<QNodeDefinition> nodeDefinitions = new LinkedList<QNodeDefinition>();
while (currentTokenEquals(Lexer.PROPERTY_DEFINITION) || currentTokenEquals(Lexer.CHILD_NODE_DEFINITION)) {
if (currentTokenEquals(Lexer.PROPERTY_DEFINITION)) {
QPropertyDefinitionBuilder pd = ntd.newQPropertyDefinition();
@@ -347,7 +398,10 @@
pd.setOnParentVersion(OnParentVersionAction.COPY);
pd.setProtected(false);
pd.setRequiredType(PropertyType.STRING);
- pd.setValueConstraints(EMPTY_VALUE_CONSTRAINTS);
+ pd.setValueConstraints(QValueConstraint.EMPTY_ARRAY);
+ pd.setFullTextSearchable(true);
+ pd.setQueryOrderable(true);
+ pd.setAvailableQueryOperators(Operator.getAllQueryOperators());
nextToken();
doPropertyDefinition(pd, ntd);
@@ -370,19 +424,16 @@
nodeDefinitions.add(nd.build());
}
}
-
- ntd.setPropertyDefs((QPropertyDefinition[]) propertyDefinitions
- .toArray(new QPropertyDefinition[0]));
-
- ntd.setChildNodeDefs((QNodeDefinition[]) nodeDefinitions.toArray(new QNodeDefinition[0]));
+ ntd.setPropertyDefs(propertyDefinitions.toArray(new QPropertyDefinition[propertyDefinitions.size()]));
+ ntd.setChildNodeDefs(nodeDefinitions.toArray(new QNodeDefinition[nodeDefinitions.size()]));
}
/**
* processes the property definition
*
- * @param pd
- * @param ntd
- * @throws ParseException
+ * @param pd property definition builder
+ * @param ntd declaring nodetype definition builder
+ * @throws ParseException if an error during parsing occurs
*/
private void doPropertyDefinition(QPropertyDefinitionBuilder pd, QNodeTypeDefinitionBuilder ntd)
throws ParseException {
@@ -401,8 +452,8 @@
/**
* processes the property type
*
- * @param pd
- * @throws ParseException
+ * @param pd property definition builder
+ * @throws ParseException if an error during parsing occurs
*/
private void doPropertyType(QPropertyDefinitionBuilder pd) throws ParseException {
if (!currentTokenEquals(Lexer.BEGIN_TYPE)) {
@@ -448,11 +499,13 @@
/**
* processes the property attributes
*
- * @param pd
- * @param ntd
- * @throws ParseException
+ * @param pd property definition builder
+ * @param ntd declaring nodetype definition builder
+ * @throws ParseException if an error during parsing occurs
*/
- private void doPropertyAttributes(QPropertyDefinitionBuilder pd, QNodeTypeDefinitionBuilder ntd) throws ParseException {
+ private void doPropertyAttributes(QPropertyDefinitionBuilder pd,
+ QNodeTypeDefinitionBuilder ntd)
+ throws ParseException {
while (currentTokenEquals(Lexer.ATTRIBUTE)) {
if (currentTokenEquals(Lexer.PRIMARY)) {
if (ntd.getPrimaryItemName() != null) {
@@ -485,71 +538,114 @@
pd.setOnParentVersion(OnParentVersionAction.IGNORE);
} else if (currentTokenEquals(Lexer.ABORT)) {
pd.setOnParentVersion(OnParentVersionAction.ABORT);
+ } else if (currentTokenEquals(Lexer.NOFULLTEXT)) {
+ pd.setFullTextSearchable(false);
+ } else if (currentTokenEquals(Lexer.NOQUERYORDER)) {
+ pd.setQueryOrderable(false);
+ } else if (currentTokenEquals(Lexer.QUERYOPS)) {
+ doPropertyQueryOperators(pd);
}
nextToken();
}
}
/**
+ * processes the property query operators
+ *
+ * @param pd the property definition builder
+ * @throws ParseException if an error occurs
+ */
+ private void doPropertyQueryOperators(QPropertyDefinitionBuilder pd)
+ throws ParseException {
+ if (!currentTokenEquals(Lexer.QUERYOPS)) {
+ return;
+ }
+ nextToken();
+
+ String[] ops = currentToken.split(",");
+ List<String> queryOps = new LinkedList<String>();
+ for (String op : ops) {
+ String s = op.trim();
+ if (s.equals(Lexer.QUEROPS_EQUAL)) {
+ queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO);
+ } else if (s.equals(Lexer.QUEROPS_NOTEQUAL)) {
+ queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO);
+ } else if (s.equals(Lexer.QUEROPS_LESSTHAN)) {
+ queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN);
+ } else if (s.equals(Lexer.QUEROPS_LESSTHANOREQUAL)) {
+ queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO);
+ } else if (s.equals(Lexer.QUEROPS_GREATERTHAN)) {
+ queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN);
+ } else if (s.equals(Lexer.QUEROPS_GREATERTHANOREQUAL)) {
+ queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO);
+ } else if (s.equals(Lexer.QUEROPS_LIKE)) {
+ queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_LIKE);
+ } else {
+ lexer.fail("'" + s + "' is not a valid query operator");
+ }
+ }
+ pd.setAvailableQueryOperators(queryOps.toArray(new String[queryOps.size()]));
+ }
+
+ /**
* processes the property default values
*
- * @param pd
- * @throws ParseException
+ * @param pd property definition builder
+ * @throws ParseException if an error during parsing occurs
*/
- private void doPropertyDefaultValue(QPropertyDefinitionBuilder pd) throws ParseException {
+ private void doPropertyDefaultValue(QPropertyDefinitionBuilder pd)
+ throws ParseException {
if (!currentTokenEquals(Lexer.DEFAULT)) {
return;
}
- List defaultValues = new ArrayList();
+ List<QValue> defaultValues = new LinkedList<QValue>();
do {
nextToken();
- QValue value = null;
try {
- value = pd.createValue(currentToken, resolver);
+ defaultValues.add(pd.createValue(currentToken, resolver));
} catch (ValueFormatException e) {
lexer.fail("'" + currentToken + "' is not a valid string representation of a value of type " + pd.getRequiredType());
} catch (RepositoryException e) {
lexer.fail("An error occured during value conversion of '" + currentToken + "'");
}
- defaultValues.add(value);
nextToken();
} while (currentTokenEquals(Lexer.LIST_DELIMITER));
- pd.setDefaultValues((QValue[]) defaultValues.toArray(new QValue[0]));
+ pd.setDefaultValues(defaultValues.toArray(new QValue[defaultValues.size()]));
}
/**
* processes the property value constraints
*
- * @param pd
- * @throws ParseException
+ * @param pd property definition builder
+ * @throws ParseException if an error during parsing occurs
*/
- private void doPropertyValueConstraints(QPropertyDefinitionBuilder pd) throws ParseException {
+ private void doPropertyValueConstraints(QPropertyDefinitionBuilder pd)
+ throws ParseException {
if (!currentTokenEquals(Lexer.CONSTRAINT)) {
return;
}
- List constraints = new ArrayList();
+ List<QValueConstraint> constraints = new LinkedList<QValueConstraint>();
do {
nextToken();
- String constraint = null;
try {
- constraint = pd.createValueConstraint(currentToken, resolver);
+ constraints.add(pd.createValueConstraint(currentToken, resolver));
} catch (InvalidConstraintException e) {
lexer.fail("'" + currentToken + "' is not a valid constraint expression for a value of type " + pd.getRequiredType());
}
- constraints.add(constraint);
nextToken();
} while (currentTokenEquals(Lexer.LIST_DELIMITER));
- pd.setValueConstraints((String[]) constraints.toArray(new String[0]));
+ pd.setValueConstraints(constraints.toArray(new QValueConstraint[constraints.size()]));
}
/**
* processes the childnode definition
*
- * @param nd
- * @param ntd
- * @throws ParseException
+ * @param nd node definition builder
+ * @param ntd declaring nodetype definition builder
+ * @throws ParseException if an error during parsing occurs
*/
- private void doChildNodeDefinition(QNodeDefinitionBuilder nd, QNodeTypeDefinitionBuilder ntd)
+ private void doChildNodeDefinition(QNodeDefinitionBuilder nd,
+ QNodeTypeDefinitionBuilder ntd)
throws ParseException {
if (currentTokenEquals('*')) {
nd.setName(NameConstants.ANY_NAME);
@@ -565,30 +661,32 @@
/**
* processes the childnode required types
*
- * @param nd
- * @throws ParseException
+ * @param nd node definition builder
+ * @throws ParseException if an error during parsing occurs
*/
- private void doChildNodeRequiredTypes(QNodeDefinitionBuilder nd) throws ParseException {
+ private void doChildNodeRequiredTypes(QNodeDefinitionBuilder nd)
+ throws ParseException {
if (!currentTokenEquals(Lexer.BEGIN_TYPE)) {
return;
}
- List types = new ArrayList();
+ List<Name> types = new LinkedList<Name>();
do {
nextToken();
types.add(toName(currentToken));
nextToken();
} while (currentTokenEquals(Lexer.LIST_DELIMITER));
- nd.setRequiredPrimaryTypes((Name[]) types.toArray(new Name[0]));
+ nd.setRequiredPrimaryTypes(types.toArray(new Name[types.size()]));
nextToken();
}
/**
* processes the childnode default types
*
- * @param nd
- * @throws ParseException
+ * @param nd node definition builder
+ * @throws ParseException if an error during parsing occurs
*/
- private void doChildNodeDefaultType(QNodeDefinitionBuilder nd) throws ParseException {
+ private void doChildNodeDefaultType(QNodeDefinitionBuilder nd)
+ throws ParseException {
if (!currentTokenEquals(Lexer.DEFAULT)) {
return;
}
@@ -600,11 +698,13 @@
/**
* processes the childnode attributes
*
- * @param nd
- * @param ntd
- * @throws ParseException
+ * @param nd node definition builder
+ * @param ntd declaring nodetype definition builder
+ * @throws ParseException if an error during parsing occurs
*/
- private void doChildNodeAttributes(QNodeDefinitionBuilder nd, QNodeTypeDefinitionBuilder ntd) throws ParseException {
+ private void doChildNodeAttributes(QNodeDefinitionBuilder nd,
+ QNodeTypeDefinitionBuilder ntd)
+ throws ParseException {
while (currentTokenEquals(Lexer.ATTRIBUTE)) {
if (currentTokenEquals(Lexer.PRIMARY)) {
if (ntd.getPrimaryItemName() != null) {
@@ -646,7 +746,7 @@
* Converts the given string into a <code>Name</code> using the current
* namespace mapping.
*
- * @param stringName
+ * @param stringName jcr name
* @return A <code>Name</code> object.
* @throws ParseException if the conversion fails
*/
@@ -676,14 +776,14 @@
/**
* Checks if the {@link #currentToken} is semantically equal to the given
- * argument.
+ * argument ignoring the case.
*
* @param s the tokens to compare with
* @return <code>true</code> if equals; <code>false</code> otherwise.
*/
private boolean currentTokenEquals(String[] s) {
- for (int i = 0; i < s.length; i++) {
- if (currentToken.equals(s[i])) {
+ for (String value : s) {
+ if (currentToken.equalsIgnoreCase(value)) {
return true;
}
}
Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java Wed Jun 17 20:21:54 2009
@@ -19,14 +19,18 @@
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Set;
import javax.jcr.NamespaceException;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
-import javax.jcr.ValueFactory;
+import javax.jcr.query.qom.QueryObjectModelConstants;
import javax.jcr.version.OnParentVersionAction;
import org.apache.jackrabbit.spi.Name;
@@ -34,10 +38,13 @@
import org.apache.jackrabbit.spi.QNodeTypeDefinition;
import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueConstraint;
import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
import org.apache.jackrabbit.spi.commons.name.NameConstants;
import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
-import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
+import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
+import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
+import org.apache.jackrabbit.spi.commons.query.qom.Operator;
import org.apache.jackrabbit.spi.commons.value.ValueFormat;
import org.apache.jackrabbit.util.ISO9075;
@@ -85,19 +92,19 @@
/**
* namespaces(prefixes) that are used
*/
- private final HashSet usedNamespaces = new HashSet();
+ private final Set<String> usedNamespaces = new HashSet<String>();
/**
- * Creates a new nodetype writer
+ * Creates a new nodetype writer that does not include namepsaces.
*
- * @param out the underlying writer
- * @param r the namespace resolver
- * @param npResolver
- * @param valueFactory
- */
- public CompactNodeTypeDefWriter(Writer out, NamespaceResolver r, NamePathResolver npResolver,
- ValueFactory valueFactory) {
- this(out, r, npResolver, valueFactory, false);
+ * @param out the underlaying writer
+ * @param r the naespace resolver
+ * @param npResolver name-path resolver
+ */
+ public CompactNodeTypeDefWriter(Writer out,
+ NamespaceResolver r,
+ NamePathResolver npResolver) {
+ this(out, r, npResolver, false);
}
/**
@@ -105,12 +112,13 @@
*
* @param out the underlaying writer
* @param r the naespace resolver
- * @param npResolver
- * @param valueFactory
+ * @param npResolver name-path resolver
* @param includeNS if <code>true</code> all used namespace decl. are also
*/
- public CompactNodeTypeDefWriter(Writer out, NamespaceResolver r, NamePathResolver npResolver,
- ValueFactory valueFactory, boolean includeNS) {
+ public CompactNodeTypeDefWriter(Writer out,
+ NamespaceResolver r,
+ NamePathResolver npResolver,
+ boolean includeNS) {
this.resolver = r;
this.npResolver = npResolver;
if (includeNS) {
@@ -126,20 +134,19 @@
* Writes the given list of QNodeTypeDefinition to the output writer including the
* used namespaces.
*
- * @param l
- * @param r
- * @param npResolver
- * @param valueFactory
- * @param out
- * @throws IOException
- */
- public static void write(List l, NamespaceResolver r, NamePathResolver npResolver,
- ValueFactory valueFactory, Writer out)
+ * @param defs collection of definitions
+ * @param r namespace resolver
+ * @param npResolver name-path resolver
+ * @param out output writer
+ * @throws IOException if an I/O error occurs
+ */
+ public static void write(Collection<QNodeTypeDefinition> defs,
+ NamespaceResolver r,
+ NamePathResolver npResolver,
+ Writer out)
throws IOException {
- CompactNodeTypeDefWriter w = new CompactNodeTypeDefWriter(out, r, npResolver, valueFactory, true);
- Iterator iter = l.iterator();
- while (iter.hasNext()) {
- QNodeTypeDefinition def = (QNodeTypeDefinition) iter.next();
+ CompactNodeTypeDefWriter w = new CompactNodeTypeDefWriter(out, r, npResolver, true);
+ for (QNodeTypeDefinition def : defs) {
w.write(def);
}
w.close();
@@ -148,8 +155,8 @@
/**
* Write one QNodeTypeDefinition to this writer
*
- * @param ntd
- * @throws IOException
+ * @param ntd node type definition
+ * @throws IOException if an I/O error occurs
*/
public void write(QNodeTypeDefinition ntd) throws IOException {
writeName(ntd);
@@ -161,10 +168,22 @@
}
/**
+ * Write one QNodeTypeDefinition to this writer
+ *
+ * @param defs node type definitions
+ * @throws IOException if an I/O error occurs
+ */
+ public void write(Collection<QNodeTypeDefinition> defs) throws IOException {
+ for (QNodeTypeDefinition def : defs) {
+ write(def);
+ }
+ }
+
+ /**
* Flushes all pending write operations and Closes this writer. please note,
* that the underlying writer remains open.
*
- * @throws IOException
+ * @throws IOException if an I/O error occurs
*/
public void close() throws IOException {
if (nsWriter != null) {
@@ -180,6 +199,8 @@
/**
* write name
+ * @param ntd node type definition
+ * @throws IOException if an I/O error occurs
*/
private void writeName(QNodeTypeDefinition ntd) throws IOException {
out.write("[");
@@ -189,60 +210,79 @@
/**
* write supertypes
+ * @param ntd node type definition
+ * @throws IOException if an I/O error occurs
*/
private void writeSupertypes(QNodeTypeDefinition ntd) throws IOException {
- Name[] sta = ntd.getSupertypes();
String delim = " > ";
- for (int i = 0; i < sta.length; i++) {
+ for (Name name : ntd.getSupertypes()) {
out.write(delim);
- out.write(resolve(sta[i]));
+ out.write(resolve(name));
delim = ", ";
}
}
/**
* write options
+ * @param ntd node type definition
+ * @throws IOException if an I/O error occurs
*/
private void writeOptions(QNodeTypeDefinition ntd) throws IOException {
+ List<String> options = new LinkedList<String>();
+ if (ntd.isAbstract()) {
+ options.add(Lexer.ABSTRACT[0]);
+ }
if (ntd.hasOrderableChildNodes()) {
- out.write("\n" + INDENT);
- out.write("orderable");
- if (ntd.isMixin()) {
- out.write(" mixin");
+ options.add(Lexer.ORDERABLE[0]);
+ }
+ if (ntd.isMixin()) {
+ options.add(Lexer.MIXIN[0]);
+ }
+ if (!ntd.isQueryable()) {
+ options.add(Lexer.NOQUERY[0]);
+ }
+ if (ntd.getPrimaryItemName() != null) {
+ options.add(Lexer.PRIMARYITEM[0]);
+ options.add(resolve(ntd.getPrimaryItemName()));
+ }
+ for (int i = 0; i < options.size(); i++) {
+ if (i == 0) {
+ out.write("\n" + INDENT);
+ } else {
+ out.write(" ");
}
- } else if (ntd.isMixin()) {
- out.write("\n" + INDENT);
- out.write("mixin");
+ out.write(options.get(i));
}
}
/**
* write prop defs
+ * @param ntd node type definition
+ * @throws IOException if an I/O error occurs
*/
private void writePropDefs(QNodeTypeDefinition ntd) throws IOException {
- QPropertyDefinition[] pda = ntd.getPropertyDefs();
- for (int i = 0; i < pda.length; i++) {
- QPropertyDefinition pd = pda[i];
- writePropDef(ntd, pd);
+ for (QPropertyDefinition pd : ntd.getPropertyDefs()) {
+ writePropDef(pd);
}
}
/**
* write node defs
+ * @param ntd node type definition
+ * @throws IOException if an I/O error occurs
*/
private void writeNodeDefs(QNodeTypeDefinition ntd) throws IOException {
- QNodeDefinition[] nda = ntd.getChildNodeDefs();
- for (int i = 0; i < nda.length; i++) {
- QNodeDefinition nd = nda[i];
- writeNodeDef(ntd, nd);
+ for (QNodeDefinition nd : ntd.getChildNodeDefs()) {
+ writeNodeDef(nd);
}
}
/**
* write prop def
- * @param pd
+ * @param pd property definition
+ * @throws IOException if an I/O error occurs
*/
- private void writePropDef(QNodeTypeDefinition ntd, QPropertyDefinition pd) throws IOException {
+ private void writePropDef(QPropertyDefinition pd) throws IOException {
out.write("\n" + INDENT + "- ");
Name name = pd.getName();
@@ -256,7 +296,6 @@
out.write(PropertyType.nameFromValue(pd.getRequiredType()).toLowerCase());
out.write(")");
writeDefaultValues(pd.getDefaultValues());
- out.write(ntd.getPrimaryItemName() != null && ntd.getPrimaryItemName().equals(pd.getName()) ? " primary" : "");
if (pd.isMandatory()) {
out.write(" mandatory");
}
@@ -273,23 +312,59 @@
out.write(" ");
out.write(OnParentVersionAction.nameFromValue(pd.getOnParentVersion()).toLowerCase());
}
+ if (!pd.isFullTextSearchable()) {
+ out.write(" nofulltext");
+ }
+ if (!pd.isQueryOrderable()) {
+ out.write(" noqueryorder");
+ }
+ String[] qops = pd.getAvailableQueryOperators();
+ if (qops != null && qops.length > 0) {
+ List<String> opts = new ArrayList<String>(Arrays.asList(qops));
+ List<String> defaultOps = Arrays.asList(Operator.getAllQueryOperators());
+ if (!opts.containsAll(defaultOps)) {
+ out.write(" queryops '");
+ String delim = "";
+ for (String opt: opts) {
+ out.write(delim);
+ delim= ", ";
+ if (opt.equals(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO)) {
+ out.write(Lexer.QUEROPS_EQUAL);
+ } else if (opt.equals(QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO)) {
+ out.write(Lexer.QUEROPS_NOTEQUAL);
+ } else if (opt.equals(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN)) {
+ out.write(Lexer.QUEROPS_GREATERTHAN);
+ } else if (opt.equals(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO)) {
+ out.write(Lexer.QUEROPS_GREATERTHANOREQUAL);
+ } else if (opt.equals(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN)) {
+ out.write(Lexer.QUEROPS_LESSTHAN);
+ } else if (opt.equals(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO)) {
+ out.write(Lexer.QUEROPS_LESSTHANOREQUAL);
+ } else if (opt.equals(QueryObjectModelConstants.JCR_OPERATOR_LIKE)) {
+ out.write(Lexer.QUEROPS_LIKE);
+ }
+ }
+ out.write("'");
+ }
+ }
writeValueConstraints(pd.getValueConstraints(), pd.getRequiredType());
}
/**
* write default values
- * @param dva
+ * @param dva default value
+ * @throws IOException if an I/O error occurs
*/
private void writeDefaultValues(QValue[] dva) throws IOException {
if (dva != null && dva.length > 0) {
String delim = " = '";
- for (int i = 0; i < dva.length; i++) {
+ for (QValue value : dva) {
out.write(delim);
try {
- String str = ValueFormat.getJCRString(dva[i], npResolver);
+ String str = ValueFormat.getJCRString(value, npResolver);
out.write(escape(str));
} catch (RepositoryException e) {
- out.write(escape(dva[i].toString()));
+ out.write(escape(value.toString()));
}
out.write("'");
delim = ", '";
@@ -299,9 +374,11 @@
/**
* write value constraints
- * @param vca
+ * @param vca value constraint
+ * @param type value type
+ * @throws IOException if an I/O error occurs
*/
- private void writeValueConstraints(String[] vca, int type) throws IOException {
+ private void writeValueConstraints(QValueConstraint[] vca, int type) throws IOException {
if (vca != null && vca.length > 0) {
String vc = convertConstraint(vca[0], type);
out.write(" < '");
@@ -316,34 +393,29 @@
}
}
- private String convertConstraint(String vc, int type) {
- if (type == PropertyType.REFERENCE
- || type == PropertyType.WEAKREFERENCE
- || type == PropertyType.NAME
- || type == PropertyType.PATH) {
- if (type == PropertyType.REFERENCE
- || type == PropertyType.WEAKREFERENCE) {
- type = PropertyType.NAME;
- }
-
- try {
- QValue qv = QValueFactoryImpl.getInstance().create(vc, type);
- vc = ValueFormat.getJCRString(qv, npResolver);
- }
- catch (RepositoryException e) {
- // ignore -> return unconverted constraint
- }
+ /**
+ * Converts the constraint to a jcr value
+ * @param vc value constraint string
+ * @param type value type
+ * @return converted value
+ */
+ private String convertConstraint(QValueConstraint vc, int type) {
+ try {
+ ValueConstraint c = ValueConstraint.create(type, vc.getString());
+ return c.getDefinition(npResolver);
+ } catch (InvalidConstraintException e) {
+ // ignore -> return unconverted constraint
+ return vc.getString();
}
-
- return vc;
}
/**
* write node def
*
- * @param nd
+ * @param nd node definition
+ * @throws IOException if an I/O error occurs
*/
- private void writeNodeDef(QNodeTypeDefinition ntd, QNodeDefinition nd) throws IOException {
+ private void writeNodeDef(QNodeDefinition nd) throws IOException {
out.write("\n" + INDENT + "+ ");
Name name = nd.getName();
@@ -354,7 +426,6 @@
}
writeRequiredTypes(nd.getRequiredPrimaryTypes());
writeDefaultType(nd.getDefaultPrimaryType());
- out.write(ntd.getPrimaryItemName() != null && ntd.getPrimaryItemName().equals(nd.getName()) ? " primary" : "");
if (nd.isMandatory()) {
out.write(" mandatory");
}
@@ -375,22 +446,23 @@
/**
* Write item def name
- * @param name
- * @throws IOException
+ * @param name name
+ * @throws IOException if an I/O error occurs
*/
private void writeItemDefName(Name name) throws IOException {
out.write(resolve(name));
}
/**
* write required types
- * @param reqTypes
+ * @param reqTypes required type names
+ * @throws IOException if an I/O error occurs
*/
private void writeRequiredTypes(Name[] reqTypes) throws IOException {
if (reqTypes != null && reqTypes.length > 0) {
String delim = " (";
- for (int i = 0; i < reqTypes.length; i++) {
+ for (Name reqType : reqTypes) {
out.write(delim);
- out.write(resolve(reqTypes[i]));
+ out.write(resolve(reqType));
delim = ", ";
}
out.write(")");
@@ -399,7 +471,8 @@
/**
* write default types
- * @param defType
+ * @param defType default type name
+ * @throws IOException if an I/O error occurs
*/
private void writeDefaultType(Name defType) throws IOException {
if (defType != null && !defType.getLocalName().equals("*")) {
@@ -410,8 +483,9 @@
/**
* resolve
- * @param name
+ * @param name name to resolve
* @return the resolved name
+ * @throws IOException if an I/O error occurs
*/
private String resolve(Name name) throws IOException {
if (name == null) {
@@ -451,7 +525,7 @@
/**
* escape
- * @param s
+ * @param s string
* @return the escaped string
*/
private String escape(String s) {
Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/Lexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/Lexer.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/Lexer.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/Lexer.java Wed Jun 17 20:21:54 2009
@@ -23,7 +23,7 @@
import java.util.Arrays;
/**
- * Lexer
+ * Lexer of the CND definition.
*/
public class Lexer {
public static final char SINGLE_QUOTE = '\'';
@@ -43,6 +43,7 @@
public static final String[] MIXIN = new String[]{"mixin", "mix", "m"};
public static final String[] ABSTRACT = new String[]{"abstract", "abs", "a"};
public static final String[] NOQUERY = new String[]{"noquery", "nq"};
+ public static final String[] QUERY = new String[]{"query", "q"};
public static final String[] PRIMARYITEM = new String[]{"primaryitem", "!"};
public static final String[] PRIMARY = new String[]{"primary", "pri", "!"};
@@ -54,12 +55,12 @@
public static final String[] NOFULLTEXT = new String[]{"nofulltext", "nof"};
public static final String[] NOQUERYORDER = new String[]{"noqueryorder", "nqord"};
- public static final String[] COPY = new String[]{"copy", "Copy", "COPY"};
- public static final String[] VERSION = new String[]{"version", "Version", "VERSION"};
- public static final String[] INITIALIZE = new String[]{"initialize", "Initialize", "INITIALIZE"};
- public static final String[] COMPUTE = new String[]{"compute", "Compute", "COMPUTE"};
- public static final String[] IGNORE = new String[]{"ignore", "Ignore", "IGNORE"};
- public static final String[] ABORT = new String[]{"abort", "Abort", "ABORT"};
+ public static final String[] COPY = new String[]{"COPY"};
+ public static final String[] VERSION = new String[]{"VERSION"};
+ public static final String[] INITIALIZE = new String[]{"INITIALIZE"};
+ public static final String[] COMPUTE = new String[]{"COMPUTE"};
+ public static final String[] IGNORE = new String[]{"IGNORE"};
+ public static final String[] ABORT = new String[]{"ABORT"};
public static final String[] ATTRIBUTE;
static {
@@ -89,20 +90,20 @@
public static final String QUEROPS_GREATERTHANOREQUAL = ">=";
public static final String QUEROPS_LIKE = "LIKE";
- public static final String[] STRING = {"string", "String", "STRING"};
- public static final String[] BINARY = {"binary", "Binary", "BINARY"};
- public static final String[] LONG = {"long", "Long", "LONG"};
- public static final String[] DOUBLE = {"double", "Double", "DOUBLE"};
- public static final String[] BOOLEAN = {"boolean", "Boolean", "BOOLEAN"};
- public static final String[] DATE = {"date", "Date", "DATE"};
- public static final String[] NAME = {"name", "Name", "NAME"};
- public static final String[] PATH = {"path", "Path", "PATH"};
- public static final String[] REFERENCE = {"reference", "Reference", "REFERENCE"};
- public static final String[] WEAKREFERENCE = {"weakreference", "WeakReference", "WEAKREFERENCE"};
- public static final String[] URI = {"uri", "Uri", "URI"};
- public static final String[] DECIMAL = {"decimal", "Decimal", "DECIMAL"};
+ public static final String[] STRING = {"STRING"};
+ public static final String[] BINARY = {"BINARY"};
+ public static final String[] LONG = {"LONG"};
+ public static final String[] DOUBLE = {"DOUBLE"};
+ public static final String[] BOOLEAN = {"BOOLEAN"};
+ public static final String[] DATE = {"DATE"};
+ public static final String[] NAME = {"NAME"};
+ public static final String[] PATH = {"PATH"};
+ public static final String[] REFERENCE = {"REFERENCE"};
+ public static final String[] WEAKREFERENCE = {"WEAKREFERENCE"};
+ public static final String[] URI = {"URI"};
+ public static final String[] DECIMAL = {"DECIMAL"};
- public static final String[] UNDEFINED = new String[]{"undefined", "Undefined", "UNDEFINED", "*"};
+ public static final String[] UNDEFINED = new String[]{"UNDEFINED", "*"};
public static final String EOF = "eof";
@@ -111,8 +112,9 @@
private final String systemId;
/**
- * Constructor
- * @param r
+ * Creates an unitialized lexer on top of the given reader.
+ * @param r the reader
+ * @param systemId informational systemid of the given stream
*/
public Lexer(Reader r, String systemId) {
this.systemId = systemId;
@@ -148,8 +150,8 @@
/**
* getNextToken
*
- * @return
- * @throws ParseException
+ * @return the next token
+ * @throws ParseException if an error during parsing occurs
*/
public String getNextToken() throws ParseException {
try {
@@ -171,14 +173,30 @@
}
}
+ /**
+ * Creates a failure exception including the current line number and systemid.
+ * @param message message
+ * @throws ParseException the created exception
+ */
public void fail(String message) throws ParseException {
throw new ParseException(message, st.lineno(), -1, systemId);
}
+ /**
+ * Creates a failure exception including the current line number and systemid.
+ * @param message message
+ * @param e root cause
+ * @throws ParseException the created exception
+ */
public void fail(String message, Throwable e) throws ParseException {
throw new ParseException(message, e, st.lineno(), -1, systemId);
}
+ /**
+ * Creates a failure exception including the current line number and systemid.
+ * @param e root cause
+ * @throws ParseException the created exception
+ */
public void fail(Throwable e) throws ParseException {
throw new ParseException(e, st.lineno(), -1, systemId);
}
Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/ParseException.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/ParseException.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/ParseException.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/ParseException.java Wed Jun 17 20:21:54 2009
@@ -40,6 +40,9 @@
/**
* Constructs a new instance of this class with <code>null</code> as its
* detail message.
+ * @param lineNumber line number
+ * @param colNumber columns number
+ * @param systemId system id
*/
public ParseException(int lineNumber, int colNumber, String systemId) {
super();
@@ -54,6 +57,9 @@
*
* @param message the detail message. The detail message is saved for
* later retrieval by the {@link #getMessage()} method.
+ * @param lineNumber line number
+ * @param colNumber columns number
+ * @param systemId system id
*/
public ParseException(String message, int lineNumber, int colNumber, String systemId) {
super(message);
@@ -68,6 +74,9 @@
*
* @param message the detail message. The detail message is saved for
* later retrieval by the {@link #getMessage()} method.
+ * @param lineNumber line number
+ * @param colNumber columns number
+ * @param systemId system id
* @param rootCause root failure cause
*/
public ParseException(String message, Throwable rootCause, int lineNumber, int colNumber, String systemId) {
@@ -80,6 +89,9 @@
/**
* Constructs a new instance of this class with the specified root cause.
*
+ * @param lineNumber line number
+ * @param colNumber columns number
+ * @param systemId system id
* @param rootCause root failure cause
*/
public ParseException(Throwable rootCause, int lineNumber, int colNumber, String systemId) {
Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/QNodeTypeDefinitionsBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/QNodeTypeDefinitionsBuilder.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/QNodeTypeDefinitionsBuilder.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/QNodeTypeDefinitionsBuilder.java Wed Jun 17 20:21:54 2009
@@ -18,6 +18,9 @@
import javax.jcr.RepositoryException;
import javax.jcr.ValueFormatException;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.nodetype.ItemDefinition;
+import javax.jcr.nodetype.NodeTypeDefinition;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.QItemDefinition;
@@ -25,8 +28,10 @@
import org.apache.jackrabbit.spi.QNodeTypeDefinition;
import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueConstraint;
import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
+import org.apache.jackrabbit.spi.commons.query.qom.Operator;
/**
* A builder for {@link QNodeTypeDefinition}s
@@ -44,10 +49,12 @@
*
* @param namespaceURI namespace uri
* @param localName local part
+ * @return the created name
* @throws IllegalArgumentException if <code>namespaceURI</code> or
* <code>localName</code> is invalid.
*/
- public abstract Name createName(String namespaceURI, String localName) throws IllegalArgumentException;
+ public abstract Name createName(String namespaceURI, String localName)
+ throws IllegalArgumentException;
/**
* A builder for a {@link QNodeTypeDefinition}
@@ -60,17 +67,22 @@
private Name primaryItemName;
private QPropertyDefinition[] propertyDefinitions;
private QNodeDefinition[] childNodeDefinitions;
+ private boolean isAbstract;
+ private boolean isQueryable = true;
/**
* Set the name of the node type definition being built
- * @param name
+ * @param name the name
+ * @see NodeTypeDefinition#getName()
*/
public void setName(Name name) {
this.name = name;
}
/**
- * @return the name of the node type definition being built or <code>null</code> if not set.
+ * @return the name of the node type definition being built or
+ * <code>null</code> if not set.
+ * @see NodeTypeDefinition#getName()
*/
public Name getName() {
return name;
@@ -78,53 +90,64 @@
/**
* Specifies the supertypes of the node type definition being built
- * @param supertypes
+ * @param supertypes the supertypes
+ * @see NodeTypeDefinition#getDeclaredSupertypeNames()
*/
public void setSupertypes(Name[] supertypes) {
this.supertypes = supertypes;
}
/**
- * Returns an array containing the names of the supertypes of the node type definition being
- * built.
+ * Returns an array containing the names of the supertypes of the node
+ * type definition being built.
*
* @return an array of supertype names
+ * @see NodeTypeDefinition#getDeclaredSupertypeNames()
*/
public Name[] getSuperTypes() {
return supertypes;
}
/**
- * @param isMixin true if building a mixin node type definition; false otherwise.
+ * @param isMixin <code>true</code> if building a mixin node type
+ * definition; <code>false</code> otherwise.
+ * @see NodeTypeDefinition#isMixin()
*/
public void setMixin(boolean isMixin) {
this.isMixin = isMixin;
}
/**
- * @return true if building a mixin node type definition; false otherwise.
+ * @return <code>true</code> if building a mixin node type definition;
+ * <code>false</code> otherwise.
+ * @see NodeTypeDefinition#isMixin()
*/
public boolean getMixin() {
return isMixin;
}
/**
- * @param isOrderable true if building a node type having orderable child nodes; false
- * otherwise.
+ * @param isOrderable <code>true</code> if building a node type having
+ * orderable child nodes; <code>false</code> otherwise.
+ * @see NodeTypeDefinition#hasOrderableChildNodes()
*/
public void setOrderableChildNodes(boolean isOrderable) {
this.isOrderable = isOrderable;
}
/**
- * @return true if building a node type having orderable child nodes; false otherwise.
+ * @return <code>true</code> if building a node type having orderable
+ * child nodes; <code>false</code> otherwise.
+ * @see NodeTypeDefinition#hasOrderableChildNodes()
*/
public boolean getOrderableChildNodes() {
return isOrderable;
}
/**
- * @param primaryItemName the name of the primary item or <code>null</code> if not set.
+ * @param primaryItemName the name of the primary item or
+ * <code>null</code> if not set.
+ * @see NodeTypeDefinition#getPrimaryItemName()
*/
public void setPrimaryItemName(Name primaryItemName) {
this.primaryItemName = primaryItemName;
@@ -132,14 +155,48 @@
/**
* @return the name of the primary item or <code>null</code> if not set.
+ * @see NodeTypeDefinition#getPrimaryItemName()
*/
public Name getPrimaryItemName() {
return primaryItemName;
}
/**
+ * @return <code>true</code> if the node type is abstract.
+ * @see NodeTypeDefinition#isAbstract()
+ */
+ public boolean getAbstract() {
+ return isAbstract;
+ }
+
+ /**
+ * @param isAbstract <code>true</code> if building a node type that is abstract.
+ * @see NodeTypeDefinition#isAbstract()
+ */
+ public void setAbstract(boolean isAbstract) {
+ this.isAbstract = isAbstract;
+ }
+
+ /**
+ * @return <code>true</code> if the node type is queryable
+ * @see NodeTypeDefinition#isQueryable()
+ */
+ public boolean getQueryable() {
+ return isQueryable;
+ }
+
+ /**
+ * @param queryable <code>true</code> if building a node type that is queryable
+ * @see NodeTypeDefinition#isQueryable()
+ */
+ public void setQueryable(boolean queryable) {
+ isQueryable = queryable;
+ }
+
+ /**
* @param propDefs an array containing the property definitions of the node type definition
* being built.
+ * @see NodeTypeDefinition#getDeclaredPropertyDefinitions()
*/
public void setPropertyDefs(QPropertyDefinition[] propDefs) {
propertyDefinitions = propDefs;
@@ -148,6 +205,7 @@
/**
* @return an array containing the property definitions of the node type definition being
* built or <code>null</code> if not set.
+ * @see NodeTypeDefinition#getDeclaredPropertyDefinitions()
*/
public QPropertyDefinition[] getPropertyDefs() {
return propertyDefinitions;
@@ -156,6 +214,7 @@
/**
* @param childDefs an array containing the child node definitions of the node type
* definition being.
+ * @see NodeTypeDefinition#getDeclaredChildNodeDefinitions()
*/
public void setChildNodeDefs(QNodeDefinition[] childDefs) {
childNodeDefinitions = childDefs;
@@ -164,6 +223,7 @@
/**
* @return an array containing the child node definitions of the node type definition being
* built or <code>null</code> if not set.
+ * @see NodeTypeDefinition#getDeclaredChildNodeDefinitions()
*/
public QNodeDefinition[] getChildNodeDefs() {
return childNodeDefinitions;
@@ -202,6 +262,7 @@
/**
* @param name the name of the child item definition being build
+ * @see ItemDefinition#getName()
*/
public void setName(Name name) {
this.name = name;
@@ -209,6 +270,7 @@
/**
* @return the name of the child item definition being build.
+ * @see ItemDefinition#getName()
*/
public Name getName() {
return name;
@@ -216,6 +278,7 @@
/**
* @param type the name of the declaring node type.
+ * @see ItemDefinition#getDeclaringNodeType()
*/
public void setDeclaringNodeType(Name type) {
declaringType = type;
@@ -223,20 +286,25 @@
/**
* @return the name of the declaring node type.
+ * @see ItemDefinition#getDeclaringNodeType()
*/
public Name getDeclaringNodeType() {
return declaringType;
}
/**
- * @param autocreate true if building a 'autocreate' child item definition, false otherwise.
+ * @param autocreate <code>true</code> if building a 'autocreate' child item
+ * definition, false otherwise.
+ * @see ItemDefinition#isAutoCreated()
*/
public void setAutoCreated(boolean autocreate) {
isAutocreated = autocreate;
}
/**
- * @return true if building a 'autocreate' child item definition, false otherwise.
+ * @return <code>true</code> if building a 'autocreate' child item
+ * definition, false otherwise.
+ * @see ItemDefinition#isAutoCreated()
*/
public boolean getAutoCreated() {
return isAutocreated;
@@ -244,6 +312,7 @@
/**
* @param onParent the 'onParentVersion' attribute of the child item definition being built
+ * @see ItemDefinition#getOnParentVersion()
*/
public void setOnParentVersion(int onParent) {
onParentVersion = onParent;
@@ -251,34 +320,43 @@
/**
* @return the 'onParentVersion' attribute of the child item definition being built
+ * @see ItemDefinition#getOnParentVersion()
*/
public int getOnParentVersion() {
return onParentVersion;
}
/**
- * @param isProtected true if building a 'protected' child item definition, false otherwise.
+ * @param isProtected <code>true</code> if building a 'protected' child
+ * item definition, false otherwise.
+ * @see ItemDefinition#isProtected()
*/
public void setProtected(boolean isProtected) {
this.isProtected = isProtected;
}
/**
- * @return true if building a 'protected' child item definition, false otherwise.
+ * @return <code>true</code> if building a 'protected' child item
+ * definition, false otherwise.
+ * @see ItemDefinition#isProtected()
*/
public boolean getProtected() {
return isProtected;
}
/**
- * @param isMandatory true if building a 'mandatory' child item definition, false otherwise.
+ * @param isMandatory <code>true</code> if building a 'mandatory' child
+ * item definition, false otherwise.
+ * @see ItemDefinition#isMandatory()
*/
public void setMandatory(boolean isMandatory) {
this.isMandatory = isMandatory;
}
/**
- * @return true if building a 'mandatory' child item definition, false otherwise.
+ * @return <code>true</code> if building a 'mandatory' child item
+ * definition, false otherwise.
+ * @see ItemDefinition#isMandatory()
*/
public boolean getMandatory() {
return isMandatory;
@@ -286,16 +364,22 @@
}
/**
- * A builder for a {@link QNodeDefinition}
+ * A builder for a {@link QPropertyDefinition}
+ * @see PropertyDefinition
*/
public abstract class QPropertyDefinitionBuilder extends QItemDefinitionBuilder {
+
private int requiredType;
- private String[] valueConstraints;
+ private QValueConstraint[] valueConstraints;
private QValue[] defaultValues;
private boolean isMultiple;
+ private boolean fullTextSearchable = true;
+ private boolean queryOrderable = true;
+ private String[] queryOperators = Operator.getAllQueryOperators();
/**
* @param type the required type of the property definition being built.
+ * @see PropertyDefinition#getRequiredType()
*/
public void setRequiredType(int type) {
requiredType = type;
@@ -303,6 +387,7 @@
/**
* @return the required type of the property definition being built.
+ * @see PropertyDefinition#getRequiredType()
*/
public int getRequiredType() {
return requiredType;
@@ -310,20 +395,23 @@
/**
* @param constraints array of value constraints of the property definition being built.
+ * @see PropertyDefinition#getValueConstraints()
*/
- public void setValueConstraints(String[] constraints) {
+ public void setValueConstraints(QValueConstraint[] constraints) {
valueConstraints = constraints;
}
/**
* @return array of value constraints of the property definition being built.
+ * @see PropertyDefinition#getValueConstraints()
*/
- public String[] getValueConstraints() {
+ public QValueConstraint[] getValueConstraints() {
return valueConstraints;
}
/**
* @param values array of default values of the property definition being built.
+ * @see PropertyDefinition#getDefaultValues()
*/
public void setDefaultValues(QValue[] values) {
defaultValues = values;
@@ -332,6 +420,7 @@
/**
* @return array of default values of the property definition being built or
* <code>null</code> if no default values are defined.
+ * @see PropertyDefinition#getDefaultValues()
*/
public QValue[] getDefaultValues() {
return defaultValues;
@@ -339,6 +428,7 @@
/**
* @param isMultiple true if building a 'multiple' property definition.
+ * @see PropertyDefinition#isMultiple()
*/
public void setMultiple(boolean isMultiple) {
this.isMultiple = isMultiple;
@@ -346,30 +436,81 @@
/**
* @return true if building a 'multiple' property definition.
+ * @see PropertyDefinition#isMultiple()
*/
public boolean getMultiple() {
return isMultiple;
}
/**
+ * @return <code>true</code> if the property is fulltext searchable
+ * @see PropertyDefinition#isFullTextSearchable()
+ */
+ public boolean getFullTextSearchable() {
+ return fullTextSearchable;
+ }
+
+ /**
+ * @param fullTextSearchable <code>true</code> if building a
+ * 'fulltext searchable' property definition
+ * @see PropertyDefinition#isFullTextSearchable()
+ */
+ public void setFullTextSearchable(boolean fullTextSearchable) {
+ this.fullTextSearchable = fullTextSearchable;
+ }
+
+ /**
+ * @return <code>true</code> if the property is orderable in a query
+ * @see PropertyDefinition#isQueryOrderable()
+ */
+ public boolean getQueryOrderable() {
+ return queryOrderable;
+ }
+
+ /**
+ * @param queryOrderable <code>true</code> if the property is orderable
+ * in a query
+ * @see PropertyDefinition#isQueryOrderable()
+ */
+ public void setQueryOrderable(boolean queryOrderable) {
+ this.queryOrderable = queryOrderable;
+ }
+
+ /**
+ * @return the query operators of the property
+ * @see PropertyDefinition#getAvailableQueryOperators()
+ */
+ public String[] getAvailableQueryOperators() {
+ return queryOperators;
+ }
+
+ /**
+ * @param queryOperators the query operators of the property
+ * @see PropertyDefinition#getAvailableQueryOperators()
+ */
+ public void setAvailableQueryOperators(String[] queryOperators) {
+ this.queryOperators = queryOperators;
+ }
+
+ /**
* Validate the given <code>constraint</code> and resolve any prefixes.
*
- * @param constraint
- * @param resolver
+ * @param constraint the contraint
+ * @param resolver the resolver
* @return A syntactically valid value constrained which refers to
* internal names and paths representations only.
* @throws InvalidConstraintException if <code>constraint</code> cannot
* be converted to a valid value constrained.
*/
- public abstract String createValueConstraint(String constraint, NamePathResolver resolver)
+ public abstract QValueConstraint createValueConstraint(String constraint, NamePathResolver resolver)
throws InvalidConstraintException;
/**
* Create a new <code>QValue</code> for <code>value</code> of the type this instance
* represents using the given <code>resolver</code>.
*
- * @param value
- * @param resolver
+ * @param value the value
+ * @param resolver the resolver
* @return a new <code>QValue</code>.
* @throws ValueFormatException If the given <code>value</code> cannot be converted to the
* specified <code>type</code>.
Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/QNodeTypeDefinitionsBuilderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/QNodeTypeDefinitionsBuilderImpl.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/QNodeTypeDefinitionsBuilderImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/QNodeTypeDefinitionsBuilderImpl.java Wed Jun 17 20:21:54 2009
@@ -25,6 +25,7 @@
import org.apache.jackrabbit.spi.QNodeTypeDefinition;
import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueConstraint;
import org.apache.jackrabbit.spi.commons.QNodeDefinitionImpl;
import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl;
@@ -72,7 +73,10 @@
return new QNodeTypeDefinitionImpl(
this.getName(),
this.getSuperTypes(),
+ null,
this.getMixin(),
+ this.getAbstract(),
+ this.getQueryable(),
this.getOrderableChildNodes(),
this.getPrimaryItemName(),
this.getPropertyDefs(),
@@ -93,10 +97,10 @@
.getInstance());
}
- public String createValueConstraint(String constraint, NamePathResolver resolver)
+ public QValueConstraint createValueConstraint(String constraint, NamePathResolver resolver)
throws InvalidConstraintException {
- return ValueConstraint.create(getRequiredType(), constraint, resolver).getQualifiedDefinition();
+ return ValueConstraint.create(getRequiredType(), constraint, resolver);
}
public QPropertyDefinition build() {
@@ -110,7 +114,10 @@
this.getDefaultValues(),
this.getMultiple(),
this.getRequiredType(),
- this.getValueConstraints());
+ this.getValueConstraints(),
+ this.getAvailableQueryOperators(),
+ this.getFullTextSearchable(),
+ this.getQueryOrderable());
}
}
Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java Wed Jun 17 20:21:54 2009
@@ -49,15 +49,15 @@
/**
* @see ValueConstraint#check(QValue)
*/
- void check(QValue value) throws ConstraintViolationException, RepositoryException {
+ public void check(QValue value) throws ConstraintViolationException, RepositoryException {
if (value == null) {
- throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
+ throw new ConstraintViolationException("null value does not satisfy the constraint '" + getString() + "'");
}
switch (value.getType()) {
case PropertyType.BOOLEAN:
- boolean b = Boolean.valueOf(value.getString()).booleanValue();
+ boolean b = Boolean.valueOf(value.getString());
if (b != reqBool) {
- throw new ConstraintViolationException("'" + b + "' does not satisfy the constraint '" + getQualifiedDefinition() + "'");
+ throw new ConstraintViolationException("'" + b + "' does not satisfy the constraint '" + getString() + "'");
}
return;
Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java Wed Jun 17 20:21:54 2009
@@ -106,20 +106,20 @@
private void check(Calendar cal) throws ConstraintViolationException {
if (cal == null) {
- throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
+ throw new ConstraintViolationException("null value does not satisfy the constraint '" + getString() + "'");
}
if (lowerLimit != null) {
if (lowerInclusive) {
if (cal.getTimeInMillis() < lowerLimit.getTimeInMillis()) {
throw new ConstraintViolationException(cal
+ " does not satisfy the constraint '"
- + getQualifiedDefinition() + "'");
+ + getString() + "'");
}
} else {
if (cal.getTimeInMillis() <= lowerLimit.getTimeInMillis()) {
throw new ConstraintViolationException(cal
+ " does not satisfy the constraint '"
- + getQualifiedDefinition() + "'");
+ + getString() + "'");
}
}
}
@@ -128,13 +128,13 @@
if (cal.getTimeInMillis() > upperLimit.getTimeInMillis()) {
throw new ConstraintViolationException(cal
+ " does not satisfy the constraint '"
- + getQualifiedDefinition() + "'");
+ + getString() + "'");
}
} else {
if (cal.getTimeInMillis() >= upperLimit.getTimeInMillis()) {
throw new ConstraintViolationException(cal
+ " does not satisfy the constraint '"
- + getQualifiedDefinition() + "'");
+ + getString() + "'");
}
}
}
@@ -143,9 +143,9 @@
/**
* @see ValueConstraint#check(QValue)
*/
- void check(QValue value) throws ConstraintViolationException, RepositoryException {
+ public void check(QValue value) throws ConstraintViolationException, RepositoryException {
if (value == null) {
- throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
+ throw new ConstraintViolationException("null value does not satisfy the constraint '" + getString() + "'");
}
switch (value.getType()) {
case PropertyType.DATE:
Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java Wed Jun 17 20:21:54 2009
@@ -67,23 +67,23 @@
* qualified <code>Name</code> into a JCR name.
*
* @see ValueConstraint#getDefinition(NamePathResolver)
- * @param resolver
+ * @param resolver name-path resolver
*/
public String getDefinition(NamePathResolver resolver) {
try {
return resolver.getJCRName(name);
} catch (NamespaceException e) {
// should never get here, return raw definition as fallback
- return getQualifiedDefinition();
+ return getString();
}
}
/**
* @see ValueConstraint#check(QValue)
*/
- void check(QValue value) throws ConstraintViolationException, RepositoryException {
+ public void check(QValue value) throws ConstraintViolationException, RepositoryException {
if (value == null) {
- throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
+ throw new ConstraintViolationException("null value does not satisfy the constraint '" + getString() + "'");
}
switch (value.getType()) {
case PropertyType.NAME:
@@ -91,7 +91,7 @@
if (!name.equals(n)) {
throw new ConstraintViolationException(n
+ " does not satisfy the constraint '"
- + getQualifiedDefinition() + "'");
+ + getString() + "'");
}
return;
Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java Wed Jun 17 20:21:54 2009
@@ -74,7 +74,7 @@
throw new InvalidConstraintException(msg);
}
if (lowerLimit != null && upperLimit != null) {
- if (lowerLimit.doubleValue() > upperLimit.doubleValue()) {
+ if (lowerLimit > upperLimit) {
String msg = "'" + definition
+ "' is not a valid value constraint format for numeric types: lower-limit exceeds upper-limit";
log.debug(msg);
@@ -98,31 +98,31 @@
private void check(double number) throws ConstraintViolationException {
if (lowerLimit != null) {
if (lowerInclusive) {
- if (number < lowerLimit.doubleValue()) {
+ if (number < lowerLimit) {
throw new ConstraintViolationException(number
+ " does not satisfy the constraint '"
- + getQualifiedDefinition() + "'");
+ + getString() + "'");
}
} else {
- if (number <= lowerLimit.doubleValue()) {
+ if (number <= lowerLimit) {
throw new ConstraintViolationException(number
+ " does not satisfy the constraint '"
- + getQualifiedDefinition() + "'");
+ + getString() + "'");
}
}
}
if (upperLimit != null) {
if (upperInclusive) {
- if (number > upperLimit.doubleValue()) {
+ if (number > upperLimit) {
throw new ConstraintViolationException(number
+ " does not satisfy the constraint '"
- + getQualifiedDefinition() + "'");
+ + getString() + "'");
}
} else {
- if (number >= upperLimit.doubleValue()) {
+ if (number >= upperLimit) {
throw new ConstraintViolationException(number
+ " does not satisfy the constraint '"
- + getQualifiedDefinition() + "'");
+ + getString() + "'");
}
}
}
@@ -131,10 +131,10 @@
/**
* @see ValueConstraint#check(QValue)
*/
- void check(QValue value) throws ConstraintViolationException, RepositoryException {
+ public void check(QValue value) throws ConstraintViolationException, RepositoryException {
if (value == null) {
throw new ConstraintViolationException("null value does not satisfy the constraint '"
- + getQualifiedDefinition() + "'");
+ + getString() + "'");
}
switch (value.getType()) {
case PropertyType.LONG: