[jbosstools-commits] JBoss Tools SVN: r39293 - in trunk/modeshape: plugins/org.jboss.tools.modeshape.jcr/META-INF and 4 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Mon Mar 5 14:30:13 EST 2012
Author: elvisisking
Date: 2012-03-05 14:30:11 -0500 (Mon, 05 Mar 2012)
New Revision: 39293
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/.settings/org.eclipse.jdt.core.prefs
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/META-INF/MANIFEST.MF
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/MultiValidationStatus.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Utils.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ValidationStatus.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndElement.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndNotationPreferences.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndTokenizer.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/LocalName.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Abstract.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/AttributeState.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Autocreated.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultType.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultValues.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ListAttributeState.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mandatory.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mixin.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Multiple.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoFullText.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoQueryOrder.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeAttributes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeTypeAttributes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/OnParentVersion.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Orderable.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItem.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyAttributes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyType.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyValue.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Protected.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/QueryOperators.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Queryable.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SameNameSiblings.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ValueConstraints.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java
Log:
JBIDE-10702 Editor for JCR Compact Node Definition (CND) files. Mostly javadoc changes.
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/.settings/org.eclipse.jdt.core.prefs 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/.settings/org.eclipse.jdt.core.prefs 2012-03-05 19:30:11 UTC (rev 39293)
@@ -1,8 +1,22 @@
-#Wed Feb 08 09:55:05 EST 2012
+#Fri Mar 02 10:43:25 CST 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=error
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected
org.eclipse.jdt.core.compiler.source=1.6
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/META-INF/MANIFEST.MF
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/META-INF/MANIFEST.MF 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/META-INF/MANIFEST.MF 2012-03-05 19:30:11 UTC (rev 39293)
@@ -9,3 +9,6 @@
Bundle-ClassPath: .
Import-Package: org.eclipse.osgi.util
Require-Bundle: org.jboss.tools.modeshape.client
+Export-Package: org.jboss.tools.modeshape.jcr,
+ org.jboss.tools.modeshape.jcr.cnd,
+ org.jboss.tools.modeshape.jcr.cnd.attributes
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -14,62 +14,313 @@
*/
public final class Messages extends NLS {
+ /**
+ * The name for the child definition's name property.
+ */
public static String childDefinitionName;
+
+ /**
+ * A message indicating the CND has no namespace or node type definitions.
+ */
public static String cndHasNoNamespacesOrNodeTypeDefinitions;
+
+ /**
+ * A message indicating a child node definition has a default type but that has been marked as a variant. One parameter, the
+ * child node definition name, is required.
+ */
public static String defaultTypeExistsButMarkedAsVariant;
+
+ /**
+ * The name for the child definition's default type property.
+ */
public static String defaultTypeName;
+
+ /**
+ * The name for the property definition's default value property.
+ */
public static String defaultValue;
+
+ /**
+ * A message indicating a property definition has default values but that property has been marked as a variant. One parameter,
+ * the property definition name, is required.
+ */
public static String defaultValuesExistButMarkedAsVariant;
+
+ /**
+ * A message indicating more than one child node definition has the same name. Two parameters, the property definition name and
+ * the child node name, are required.
+ */
public static String duplicateChildNodeDefinitionName;
+
+ /**
+ * A message indicating a property definition has duplicate default values. Parameters for the duplicate value and the property
+ * definition name are required.
+ */
public static String duplicateDefaultValue;
+
+ /**
+ * A message indicating multiple namespace mappings have the same prefix. One parameter, the duplicate prefix, is required.
+ */
public static String duplicateNamespacePrefix;
+
+ /**
+ * A message indicating multiple namespace mappings have the same prefix. One parameter, the prefix, is required.
+ */
public static String duplicateNamespaceUri;
+
+ /**
+ * A message indicating multiple node type definitions with the same name exist. One parameter, the duplicate node type
+ * definition name, is required.
+ */
public static String duplicateNodeTypeDefinitionName;
+
+ /**
+ * A message indicating multiple property definitions with the same name exist. One parameter, the duplicate property definition
+ * name, is required.
+ */
public static String duplicatePropertyDefinitionName;
+
+ /**
+ * A message indicating duplicate query operators of a property definition exist. The parameters of property definition name and
+ * the duplicate query operator are required.
+ */
public static String duplicateQueryOperator;
+
+ /**
+ * A message indicating duplicate required types of a child node definition exist. The parameters of child node definition name
+ * and the duplicate required type name are required.
+ */
public static String duplicateRequiredType;
+
+ /**
+ * A message indicating duplicate super types of a node type definition exist. The parameters of node type definition name and
+ * the duplicate super type name are required.
+ */
public static String duplicateSuperType;
+
+ /**
+ * A message indicating duplicate value constraints of a property definition exist. The parameters of property definition name
+ * and the duplicate value constraint are required.
+ */
public static String duplicateValueConstraint;
+
+ /**
+ * A message indicating the property definition is missing default values. One parameter, the property definition name, is
+ * required.
+ */
public static String emptyDefaultValues;
+
+ /**
+ * A message indicating a name of a property definition, child node definition, or node type definition is missing. One
+ * parameter, the string identifying the name, is required.
+ */
public static String emptyLocalName;
+
+ /**
+ * A message indicating a property definition has an empty query operator. One parameter, the property definition name, is
+ * required.
+ */
public static String emptyQueryOperator;
+
+ /**
+ * A message indicating a property definition is missing query operators. One parameter, the property definition name, is
+ * required.
+ */
public static String emptyQueryOperators;
+
+ /**
+ * A message indicating a child node definition is missing required types. One parameter, the property definition name, is
+ * required.
+ */
public static String emptyRequiredTypes;
+
+ /**
+ * A message indicating a node type definition is missing super types. One parameter, the node type definition name, is
+ * required.
+ */
public static String emptySuperTypes;
+
+ /**
+ * A message indicating a missing value was found. One parameter, a string identifying what the value is, is required.
+ */
public static String emptyValue;
+
+ /**
+ * A message indicating a property definition is missing value constraints. One parameter, the property definition name, is
+ * required.
+ */
public static String emptyValueConstraints;
- public static String errorImportingCndContent;
+
+ /**
+ * A message indicating an invalid value was found. The parameters of property value, property type, and property definition are
+ * required.
+ */
public static String errorValidatingPropertyValueForType;
+
+ /**
+ * A message indicating the parser could not parse the current toke as it was not a namespace mapping or node type definition.
+ * The parameters of parser token value, CND line number, and CND column number are required.
+ */
public static String expectedNamespaceOrNodeDefinition;
- public static String expectedValidQueryOperator;
+
+ /**
+ * A message indicating a <code>find</code> method was called with an invalid value. One parameter, the invalid value, is
+ * required.
+ */
public static String invalidFindRequest;
+
+ /**
+ * A message indicating a <code>findUsingJcrValue</code> method was called with an invalid value. One parameter, the invalid
+ * value, is required.
+ */
public static String invalidFindUsingJcrValueRequest;
+
+ /**
+ * A message indicating a <code>getState</code> method was called with an invalid value. One parameter, the invalid value, is
+ * required.
+ */
public static String invalidGetStateRequest;
+
+ /**
+ * A message indicating an invalid query operator CND notation was found. One parameter, the invalid value, is required.
+ */
public static String invalidQueryOperator;
+
+ /**
+ * A message indicating an invalid property valid was found. The parameters of invalid property value, property type, and
+ * property definition name are required.
+ */
public static String invalidPropertyValueForType;
+
+ /**
+ * A message indicating an invalid URI was found. One parameter, the invalid URI, is required.
+ */
public static String invalidUri;
+
+ /**
+ * A message indicating a name equal to parent or self was found. One parameter, a string identifying the name, is required.
+ */
public static String localNameEqualToSelfOrParent;
+
+ /**
+ * A message indicating a with invalid characters was found. One parameter, a string identifying the name, is required.
+ */
public static String localNameHasInvalidCharacters;
+
+ /**
+ * A message used for a name when the name is <code>null</code> or empty.
+ */
public static String missingName;
+
+ /**
+ * A message indicating multiple default values were found for a single-valued property definition. One parameter, the property
+ * definition name, is required.
+ */
public static String multipleDefaultValuesForSingleValuedProperty;
+
+ /**
+ * A message indicating the <code>MULTIPLE</code> keyword was found in the CND in a place that is not valid for JCR 2.0. The
+ * parameters of CND line number and CND column number are required.
+ */
public static String multipleKeywordNotValidInJcr2CndFormat;
+
+ /**
+ * A message used for the namespace prefix attribute.
+ */
public static String namespacePrefix;
+
+ /**
+ * A message used for the namespace URI attribute.
+ */
public static String namespaceUri;
+
+ /**
+ * A message indicating a node type definition does not have any property definitions or child node definitions. One parameter,
+ * the node type definition name, is required.
+ */
public static String nodeTypeDefinitionHasNoPropertyDefinitionsOrChildNodeDefinitions;
+
+ /**
+ * A message used for the node type definition name property.
+ */
public static String nodeTypeDefinitionName;
+
+ /**
+ * A message indicating no errors, warnings, or info validation messages were found.
+ */
public static String okValidationMsg;
+
+ /**
+ * A message indicating a <code>null</code> was found. One parameter, a string identifying the object, is required.
+ */
public static String objectIsNull;
+
+ /**
+ * A message indicating a node type definition has a primary item but has been marked as a variant. One parameter, the node type
+ * definition name, is required.
+ */
public static String primaryItemExistsButMarkedAsVariant;
+
+ /**
+ * A message used for the primary item name attribute.
+ */
public static String primaryItemName;
+
+ /**
+ * A message indicating the <code>PRIMARY</code> keyword was found in the CND in a place that is not valid for JCR 2.0. The
+ * parameters of CND line number and CND column number are required.
+ */
public static String primaryKeywordNotValidInJcr2CndFormat;
+
+ /**
+ * A message used for the property definition name attribute.
+ */
public static String propertyDefinitionName;
+
+ /**
+ * A message indicating a property definition has identified supported query operators but has been marked as a variant. One
+ * parameter, the property definition name, is required.
+ */
public static String queryOperatorsExistButMarkedAsVariant;
+
+ /**
+ * A message used for the required type name property.
+ */
public static String requiredTypeName;
+
+ /**
+ * A message indicating a child node definition has identified supported required types but has been marked as a variant. One
+ * parameter, the child node definition name, is required.
+ */
public static String requiredTypesExistButMarkedAsVariant;
+
+ /**
+ * A message indicating a <code>null</code> or empty string was found. One parameter, a name identifying the string, is
+ * required.
+ */
public static String stringIsEmpty;
+
+ /**
+ * A message used for the required type name attribute.
+ */
public static String superTypeName;
+
+ /**
+ * A message indicating a node type definition has super types but has been marked as a variant. One parameter, the node type
+ * definition name, is required.
+ */
public static String superTypesExistButMarkedAsVariant;
+
+ /**
+ * A message indicating a property definition has identified value constraints but has been marked as a variant. One parameter,
+ * the property definition name, is required.
+ */
public static String valueConstraintsExistButMarkedAsVariant;
+
+ /**
+ * A message indicating a parser error occured processing a vendor block. The parameters or CND line number and CND column are
+ * required.
+ */
public static String vendorBlockWasNotClosed;
static {
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/MultiValidationStatus.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/MultiValidationStatus.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/MultiValidationStatus.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -11,7 +11,7 @@
import java.util.List;
/**
- *
+ * A validation status that can contain other statuses.
*/
public class MultiValidationStatus extends ValidationStatus {
@@ -19,15 +19,24 @@
private ValidationStatus primary = null;
+ /**
+ * Constructs an OK status.
+ */
public MultiValidationStatus() {
super(Severity.OK, Messages.okValidationMsg);
}
- public MultiValidationStatus( ValidationStatus status ) {
+ /**
+ * @param status the status used to construct (cannot be <code>null</code>)
+ */
+ public MultiValidationStatus( final ValidationStatus status ) {
super(status.getSeverity(), status.getMessage());
}
- public void add( ValidationStatus statusBeingAdded ) {
+ /**
+ * @param statusBeingAdded the status being added (cannot be <code>null</code>)
+ */
+ public void add( final ValidationStatus statusBeingAdded ) {
this.errors.add(statusBeingAdded);
if ((this.primary == null) || statusBeingAdded.getSeverity().isMoreSevere(getSeverity())) {
@@ -37,6 +46,9 @@
}
}
+ /**
+ * @return a collection of all contained statuses (never <code>null</code>)
+ */
public List<ValidationStatus> getAll() {
return this.errors;
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Utils.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Utils.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Utils.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -18,16 +18,29 @@
*/
public final class Utils {
+ /**
+ * An empty string constant.
+ */
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ /**
+ * And empty string array.
+ */
public static final String[] EMPTY_STRING_ARRAY = new String[0];
- public static boolean build( StringBuilder builder,
- boolean addDelimiter,
- String delimiter,
- String text ) {
+ /**
+ * @param builder the builder where the text will be appended (cannot be <code>null</code>)
+ * @param addDelimiter the flag indicating if a delimiter should be added
+ * @param delimiter the delimiter string added before the text if there is text (can be <code>null</code> or empty)
+ * @param text the text being appended (can be <code>null</code> or empty
+ * @return <code>true</code> if text was appened
+ */
+ public static boolean build( final StringBuilder builder,
+ final boolean addDelimiter,
+ final String delimiter,
+ final String text ) {
if (!Utils.isEmpty(text)) {
- if (addDelimiter) {
+ if (addDelimiter && !Utils.isEmpty(delimiter)) {
builder.append(delimiter);
}
@@ -38,8 +51,13 @@
return false;
}
- public static boolean equals( Object thisObject,
- Object thatObject ) {
+ /**
+ * @param thisObject the object being compared to the second object (can be <code>null</code>)
+ * @param thatObject the object being compared with the first object (can be <code>null</code>)
+ * @return <code>true</code> if both objects are <code>null</code> or are equal
+ */
+ public static boolean equals( final Object thisObject,
+ final Object thatObject ) {
if (thisObject == null) {
return (thatObject == null);
}
@@ -51,8 +69,13 @@
return thisObject.equals(thatObject);
}
- public static boolean equivalent( Collection<?> thisCollection,
- Collection<?> thatCollection ) {
+ /**
+ * @param thisCollection the collection being compared to the second collection (can be <code>null</code>)
+ * @param thatCollection the collection being compared to the first collection (can be <code>null</code>)
+ * @return <code>true</code> if both collections are <code>null</code>, both are empty, or both contain the same items
+ */
+ public static boolean equivalent( final Collection<?> thisCollection,
+ final Collection<?> thatCollection ) {
if (isEmpty(thisCollection)) {
return isEmpty(thatCollection);
}
@@ -68,8 +91,13 @@
return thisCollection.containsAll(thatCollection);
}
- public static boolean equivalent( String thisString,
- String thatString ) {
+ /**
+ * @param thisString the string being compared with the second string (can be <code>null</code> or empty)
+ * @param thatString the string being compared with the first string (can be <code>null</code> or empty)
+ * @return <code>true</code> if both are <code>null</code> or empty, or they are equal
+ */
+ public static boolean equivalent( final String thisString,
+ final String thatString ) {
if (isEmpty(thisString)) {
return isEmpty(thatString);
}
@@ -81,49 +109,83 @@
return thisString.equals(thatString);
}
- public static final int hashCode( Object... x ) {
+ /**
+ * @param x the objects used to construct the hashcode (can contain <code>null</code> objects)
+ * @return the hashcode
+ */
+ public static final int hashCode( final Object... x ) {
return HashCode.compute(x);
}
- public static boolean isEmpty( Object[] items ) {
- return ((items == null) || (items.length == 0));
+ /**
+ * @param items the collection being checked (can be <code>null</code> or empty)
+ * @return <code>true</code> if <code>null</code> or empty
+ */
+ public static boolean isEmpty( final Collection<?> items ) {
+ return ((items == null) || items.isEmpty());
}
- public static boolean isEmpty( Collection<?> items ) {
- return ((items == null) || items.isEmpty());
+ /**
+ * @param items the array being checked (can be <code>null</code> or empty)
+ * @return <code>true</code> if <code>null</code> or empty
+ */
+ public static boolean isEmpty( final Object[] items ) {
+ return ((items == null) || (items.length == 0));
}
- public static boolean isEmpty( String text ) {
+ /**
+ * @param text the string being checked (can be <code>null</code> or empty)
+ * @return <code>true</code> if <code>null</code> or empty
+ */
+ public static boolean isEmpty( final String text ) {
return ((text == null) || text.isEmpty());
}
- public static void isNotNull( Object objectBeingChecked,
+ /**
+ * @param object the object being checked (can be <code>null</code>)
+ * @param name the name of the object to use in the error message (cannot be <code>null</code>)
+ * @throws IllegalArgumentException if the object is <code>null</code>
+ */
+ public static void isNotNull( final Object object,
String name ) {
- assert ((name != null) && !name.isEmpty()) : "name is null"; //$NON-NLS-1$
+ if ((name == null) || name.isEmpty()) {
+ name = Utils.EMPTY_STRING;
+ }
- if (objectBeingChecked == null) {
+ if (object == null) {
throw new IllegalArgumentException(NLS.bind(Messages.objectIsNull, name));
}
}
- public static String[] toUpperCase(String[] items) {
+ /**
+ * @param items the items being upper-cased (cannot be <code>null</code>)
+ * @return a new collection of upper-cased items
+ */
+ public static String[] toUpperCase( final String[] items ) {
Utils.isNotNull(items, "items"); //$NON-NLS-1$
- String result[] = new String[items.length];
+ final String result[] = new String[items.length];
int i = 0;
- for (String item : items) {
+ for (final String item : items) {
result[i++] = item.toUpperCase();
}
return result;
}
- public static void verifyIsNotEmpty( String objectBeingChecked,
+ /**
+ * @param text the string being checked (can be <code>null</code> or empty)
+ * @param name the name of the object to use in the error message (cannot be <code>null</code>)
+ * @throws IllegalArgumentException if the text is <code>null</code> or empty
+ */
+ public static void verifyIsNotEmpty( final String text,
String name ) {
- assert ((name != null) && !name.isEmpty()) : "name is null"; //$NON-NLS-1$
+ if ((name == null) || name.isEmpty()) {
+ name = Utils.EMPTY_STRING;
+ }
- if (isEmpty(objectBeingChecked)) {
+ if (isEmpty(text)) {
throw new IllegalArgumentException(NLS.bind(Messages.stringIsEmpty, name));
}
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ValidationStatus.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ValidationStatus.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ValidationStatus.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -12,30 +12,6 @@
*/
public class ValidationStatus implements Comparable<ValidationStatus> {
- public enum Severity {
- ERROR,
- INFO,
- OK,
- WARNING;
-
- public boolean isMoreSevere( Severity that ) {
- if ((this == that) || (this == WARNING)) {
- return false;
- }
-
- if (this == ERROR) {
- return true;
- }
-
- if (this == INFO) {
- return (that == OK);
- }
-
- // this == OK
- return (that == WARNING);
- }
- }
-
/**
* An OK validation status with a standard, localized message.
*/
@@ -73,15 +49,26 @@
return new ValidationStatus(Severity.WARNING, message);
}
+ /**
+ * The localized message which can be displayed to the user (never <code>null</code>).
+ */
protected String message;
+
+ /**
+ * The status severity (never <code>null</code>).
+ */
protected Severity severity;
- protected ValidationStatus( Severity type,
+ /**
+ * @param severity the status severity (cannot be <code>null</code>)
+ * @param message the status localized user message (cannot be <code>null</code>)
+ */
+ protected ValidationStatus( Severity severity,
String message ) {
- assert (type != null) : "severity is null"; //$NON-NLS-1$
+ assert (severity != null) : "severity is null"; //$NON-NLS-1$
Utils.verifyIsNotEmpty(message, "message"); //$NON-NLS-1$
- this.severity = type;
+ this.severity = severity;
this.message = message;
}
@@ -151,6 +138,9 @@
return this.message;
}
+ /**
+ * @return the status severity (never <code>null</code>)
+ */
protected Severity getSeverity() {
return this.severity;
}
@@ -183,4 +173,53 @@
return (Severity.WARNING == this.severity);
}
+ /**
+ * The validation status severity.
+ */
+ public enum Severity {
+
+ /**
+ * Indicates the status is an error.
+ */
+ ERROR,
+
+ /**
+ * Indicates the status is an info.
+ */
+ INFO,
+
+ /**
+ * Indicates the status is a OK.
+ */
+ OK,
+
+ /**
+ * Indicates the status is a warning.
+ */
+ WARNING;
+
+ /**
+ * @param that the validation being compared (cannot be <code>null</code>)
+ * @return <code>true</code> if this status more severe
+ */
+ public boolean isMoreSevere( Severity that ) {
+ Utils.isNotNull(that, "that"); //$NON-NLS-1$
+
+ if ((this == that) || (this == WARNING)) {
+ return false;
+ }
+
+ if (this == ERROR) {
+ return true;
+ }
+
+ if (this == INFO) {
+ return (that == OK);
+ }
+
+ // this == OK
+ return (that == WARNING);
+ }
+ }
+
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndElement.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndElement.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndElement.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -8,23 +8,34 @@
package org.jboss.tools.modeshape.jcr.cnd;
/**
- *
+ * An element that can be found in a CND file.
*/
public interface CndElement {
- char DELIMITER = ' ';
-
- String LIST_DELIMITER = ", "; //$NON-NLS-1$
-
/**
* @param notationType the notation type (cannot be <code>null</code>)
* @return the CND notation (<code>null</code> or empty if the element is incomplete)
*/
String toCndNotation( NotationType notationType );
+ /**
+ * The type of CND notation to use.
+ */
enum NotationType {
+
+ /**
+ * The shortest form.
+ */
COMPACT,
+
+ /**
+ * An intermediate-sized form.
+ */
COMPRESSED,
+
+ /**
+ * The longest form.
+ */
LONG;
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -54,43 +54,51 @@
* instances.
*/
@NotThreadSafe
-public class CndImporter {
+public final class CndImporter {
- protected final boolean jcr170;
+ private final boolean jcr170;
+ /**
+ * Constructs an importer that is not JCR 170 compatible.
+ */
public CndImporter() {
this.jcr170 = false;
}
- public CndImporter( boolean compatibleWithPreJcr2 ) {
+ /**
+ * @param compatibleWithPreJcr2 indicates if the importer should be compatible with pre JCR 2 CND notation
+ */
+ public CndImporter( final boolean compatibleWithPreJcr2 ) {
this.jcr170 = compatibleWithPreJcr2;
}
/**
* Import the CND content from the supplied stream, placing the content into the importer's destination.
*
- * @param stream the stream containing the CND content
+ * @param file the file containing the CND content
* @param problems where any problems encountered during import should be reported
- * @param resourceName a logical name for the resource name to be used when reporting problems; may be null if there is no
- * useful name
+ * @return the CND (never <code>null</code>)
* @throws IOException if there is a problem reading from the supplied stream
*/
- public CompactNodeTypeDefinition importFrom( InputStream stream,
- Collection<Throwable> problems,
- String resourceName ) throws IOException {
- return importFrom(IoUtil.read(stream), problems, resourceName);
+ public CompactNodeTypeDefinition importFrom( final File file,
+ final Collection<Throwable> problems ) throws IOException {
+ return importFrom(IoUtil.read(file), problems, file.getCanonicalPath());
}
/**
* Import the CND content from the supplied stream, placing the content into the importer's destination.
*
- * @param file the file containing the CND content
+ * @param stream the stream containing the CND content
* @param problems where any problems encountered during import should be reported
+ * @param resourceName a logical name for the resource name to be used when reporting problems; may be null if there is no
+ * useful name
+ * @return the CND (never <code>null</code>)
* @throws IOException if there is a problem reading from the supplied stream
*/
- public CompactNodeTypeDefinition importFrom( File file,
- Collection<Throwable> problems ) throws IOException {
- return importFrom(IoUtil.read(file), problems, file.getCanonicalPath());
+ public CompactNodeTypeDefinition importFrom( final InputStream stream,
+ final Collection<Throwable> problems,
+ final String resourceName ) throws IOException {
+ return importFrom(IoUtil.read(stream), problems, resourceName);
}
/**
@@ -100,13 +108,14 @@
* @param problems where any problems encountered during import should be reported
* @param resourceName a logical name for the resource name to be used when reporting problems; may be null if there is no
* useful name
+ * @return the CND (never <code>null</code>)
*/
- public CompactNodeTypeDefinition importFrom( String content,
- Collection<Throwable> problems,
- String resourceName ) {
+ public CompactNodeTypeDefinition importFrom( final String content,
+ final Collection<Throwable> problems,
+ final String resourceName ) {
try {
return parse(content);
- } catch (RuntimeException e) {
+ } catch (final RuntimeException e) {
problems.add(e);
}
@@ -117,14 +126,15 @@
* Parse the CND content.
*
* @param content the content (cannot be <code>null</code>)
+ * @return the CND (never <code>null</code>)
* @throws ParsingException if there is a problem parsing the content
*/
- public CompactNodeTypeDefinition parse( String content ) {
+ public CompactNodeTypeDefinition parse( final String content ) {
Utils.isNotNull(content, "content is null"); //$NON-NLS-1$
- CompactNodeTypeDefinition cnd = new CompactNodeTypeDefinition();
- Tokenizer tokenizer = new CndTokenizer(false, true);
- TokenStream tokens = new TokenStream(content, tokenizer, false);
+ final CompactNodeTypeDefinition cnd = new CompactNodeTypeDefinition();
+ final Tokenizer tokenizer = new CndTokenizer(false, false);
+ final TokenStream tokens = new TokenStream(content, tokenizer, false);
tokens.start();
while (tokens.hasNext()) {
@@ -136,8 +146,8 @@
NodeTypeDefinition.NAME_NOTATION_SUFFIX)) {
parseNodeTypeDefinition(tokens, cnd);
} else {
- Position position = tokens.previousPosition();
- Object[] args = new Object[] { tokens.consume(), position.getLine(), position.getColumn() };
+ final Position position = tokens.previousPosition();
+ final Object[] args = new Object[] { tokens.consume(), position.getLine(), position.getColumn() };
throw new ParsingException(position, NLS.bind(Messages.expectedNamespaceOrNodeDefinition, args));
}
}
@@ -146,149 +156,239 @@
}
/**
- * Parse the namespace mapping statement that is next on the token stream.
+ * Parse a node type's child node definition from the next tokens on the stream.
*
- * @param tokens the tokens containing the namespace statement (cannot be <code>null</code>)
- * @param cnd the CND object representing the CND file being parsed (cannot be <code>null</code>)
+ * @param tokens the tokens containing the definition (cannot be <code>null</code>)
+ * @param nodeTypeDefn the node type being created (cannot be <code>null</code>)
* @throws ParsingException if there is a problem parsing the content
*/
- private void parseNamespaceMapping( TokenStream tokens,
- CompactNodeTypeDefinition cnd ) {
+ private void parseChildNodeDefinition( final TokenStream tokens,
+ final NodeTypeDefinition nodeTypeDefn ) {
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
- assert (cnd != null) : "cnd is null"; //$NON-NLS-1$
+ assert (nodeTypeDefn != null) : "nodeTypeDefn is null"; //$NON-NLS-1$
- tokens.consume(NamespaceMapping.NOTATION_PREFIX);
- String prefix = removeQuotes(tokens.consume());
+ tokens.consume(ChildNodeDefinition.NOTATION_PREFIX);
+ final ChildNodeDefinition childNodeDefn = new ChildNodeDefinition();
- tokens.consume(NamespaceMapping.NOTATION_DELIMITER);
- String uri = removeQuotes(tokens.consume());
+ // name
+ final String name = parseName(tokens);
- tokens.consume(NamespaceMapping.NOTATION_SUFFIX);
- cnd.addNamespaceMapping(new NamespaceMapping(prefix, uri));
+ if (!Utils.isEmpty(name)) {
+ childNodeDefn.setName(name);
+ }
+
+ // required types
+ parseRequiredPrimaryTypes(tokens, childNodeDefn);
+
+ // default types
+ parseDefaultType(tokens, childNodeDefn.getDefaultType());
+
+ // attributes
+ parseNodeAttributes(tokens, nodeTypeDefn, childNodeDefn);
+
+ // add child node definition
+ nodeTypeDefn.addChildNodeDefinition(childNodeDefn);
}
/**
- * Parse the node type definition that is next on the token stream.
+ * Parse the child node definition's default type, if they appear next on the token stream.
*
- * @param tokens the tokens containing the node type definition (cannot be <code>null</code>)
- * @param cnd the CND object representing the CND file being parsed (cannot be <code>null</code>)
+ * @param tokens the tokens containing the definition (cannot be <code>null</code>)
+ * @param defaultType the default type (cannot be <code>null</code>)
* @throws ParsingException if there is a problem parsing the content
*/
- private void parseNodeTypeDefinition( TokenStream tokens,
- CompactNodeTypeDefinition cnd ) {
+ private void parseDefaultType( final TokenStream tokens,
+ final DefaultType defaultType ) {
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
- assert (cnd != null) : "cnd is null"; //$NON-NLS-1$
+ assert (defaultType != null) : "defaultType is null"; //$NON-NLS-1$
- NodeTypeDefinition nodeType = new NodeTypeDefinition();
+ if (tokens.canConsume(DefaultType.NOTATION)) {
+ if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
+ defaultType.set(Value.VARIANT);
+ } else {
+ final String typeName = parseName(tokens);
- // name
- String name = parseNodeTypeName(tokens);
-
- if (!Utils.isEmpty(name)) {
- nodeType.setName(name);
- }
-
- // supertypes
- List<String> superTypes = parseSupertypes(tokens);
-
- if (!superTypes.isEmpty()) {
- for (String superType : superTypes) {
- nodeType.addSuperType(superType);
+ if (!Utils.isEmpty(typeName)) {
+ defaultType.setDefaultType(typeName);
+ }
}
}
- // Read the node type options (and vendor extensions) ...
- parseNodeTypeAttributes(tokens, nodeType);
-
- // Parse property and child node definitions ...
- parsePropertyOrChildNodeDefinitions(tokens, nodeType);
-
- cnd.addNodeTypeDefinition(nodeType);
}
/**
- * Parse a node type name that appears next on the token stream.
+ * Parse the property definition's default values, if they appear next on the token stream.
*
- * @param tokens the tokens containing the node type name (cannot be <code>null</code>)
- * @return the node type name
+ * @param tokens the tokens containing the definition (cannot be <code>null</code>)
+ * @param propDefn the property definition whose default values are being parsed (cannot be <code>null</code>)
* @throws ParsingException if there is a problem parsing the content
*/
- private String parseNodeTypeName( TokenStream tokens ) {
+ private void parseDefaultValues( final TokenStream tokens,
+ final PropertyDefinition propDefn ) {
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
+ assert (propDefn != null) : "propDefn is null"; //$NON-NLS-1$
- tokens.consume(NodeTypeDefinition.NAME_NOTATION_PREFIX);
- String name = parseName(tokens);
- tokens.consume(NodeTypeDefinition.NAME_NOTATION_SUFFIX);
- return name;
+ if (tokens.canConsume(DefaultValues.NOTATION_PREFIX)) {
+ final List<String> values = parseStringList(tokens);
+
+ if (!values.isEmpty()) {
+ if ((values.size() == 1) && AttributeState.VARIANT_STRING.equals(values.get(0))) {
+ propDefn.changeState(PropertyDefinition.PropertyName.DEFAULT_VALUES, Value.VARIANT);
+ } else {
+ for (final String value : values) {
+ propDefn.addDefaultValue(value);
+ }
+ }
+ }
+ }
}
/**
- * Parse an optional list of supertypes if they appear next on the token stream.
+ * Parse the name that is expected to be next on the token stream.
*
- * @param tokens the tokens containing the supertype names (cannot be <code>null</code>)
- * @return the list of supertype names (cannot be <code>null</code> but can be empty)
+ * @param tokens the tokens containing the name (cannot be <code>null</code>)
+ * @return the name (cannot be <code>null</code>)
* @throws ParsingException if there is a problem parsing the content
*/
- private List<String> parseSupertypes( TokenStream tokens ) {
- assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
-
- if (tokens.canConsume(SuperTypes.NOTATION_PREFIX)) {
- // There is at least one supertype ...
- return parseNameList(tokens);
- }
-
- return Collections.emptyList();
+ private String parseName( final TokenStream tokens ) {
+ final String value = tokens.consume();
+ return removeQuotes(value);
}
/**
- * Parse a list of strings, separated by commas. Any quotes surrounding the strings are removed.
+ * Parse a list of names, separated by commas. Any quotes surrounding the names are removed.
*
* @param tokens the tokens containing the comma-separated strings (cannot be <code>null</code>)
* @return the list of string values (cannot be <code>null</code> but can be empty)
* @throws ParsingException if there is a problem parsing the content
*/
- private List<String> parseStringList( TokenStream tokens ) {
+ private List<String> parseNameList( final TokenStream tokens ) {
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
- List<String> strings = new ArrayList<String>();
+ final List<String> names = new ArrayList<String>();
if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
- // This list is variant ...
- strings.add(AttributeState.VARIANT_STRING);
+ names.add(AttributeState.VARIANT_STRING);
} else {
// Read names until we see a ','
do {
- strings.add(removeQuotes(tokens.consume()));
+ names.add(parseName(tokens));
} while (tokens.canConsume(','));
}
- return strings;
+ return names;
}
/**
- * Parse a list of names, separated by commas. Any quotes surrounding the names are removed.
+ * Parse the namespace mapping statement that is next on the token stream.
*
- * @param tokens the tokens containing the comma-separated strings (cannot be <code>null</code>)
- * @return the list of string values (cannot be <code>null</code> but can be empty)
+ * @param tokens the tokens containing the namespace statement (cannot be <code>null</code>)
+ * @param cnd the CND object representing the CND file being parsed (cannot be <code>null</code>)
* @throws ParsingException if there is a problem parsing the content
*/
- private List<String> parseNameList( TokenStream tokens ) {
+ private void parseNamespaceMapping( final TokenStream tokens,
+ final CompactNodeTypeDefinition cnd ) {
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
+ assert (cnd != null) : "cnd is null"; //$NON-NLS-1$
- List<String> names = new ArrayList<String>();
+ tokens.consume(NamespaceMapping.NOTATION_PREFIX);
+ final String prefix = removeQuotes(tokens.consume());
- if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
- names.add(AttributeState.VARIANT_STRING);
- } else {
- // Read names until we see a ','
- do {
- names.add(parseName(tokens));
- } while (tokens.canConsume(','));
- }
+ tokens.consume(NamespaceMapping.NOTATION_DELIMITER);
+ final String uri = removeQuotes(tokens.consume());
- return names;
+ tokens.consume(NamespaceMapping.NOTATION_SUFFIX);
+ cnd.addNamespaceMapping(new NamespaceMapping(prefix, uri));
}
/**
+ * Parse the child node definition's attributes, if they appear next on the token stream.
+ *
+ * @param tokens the tokens containing the attributes (cannot be <code>null</code>)
+ * @param nodeTypeDefn the node type being created (cannot be <code>null</code>)
+ * @param childNodeDefn the child node definition (cannot be <code>null</code>)
+ * @throws ParsingException if there is a problem parsing the content
+ */
+ private void parseNodeAttributes( final TokenStream tokens,
+ final NodeTypeDefinition nodeTypeDefn,
+ final ChildNodeDefinition childNodeDefn ) {
+ assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
+ assert (nodeTypeDefn != null) : "nodeTypeDefn is null"; //$NON-NLS-1$
+ assert (childNodeDefn != null) : "childNodeDefn is null"; //$NON-NLS-1$
+
+ while (true) {
+ if (tokens.canConsumeAnyOf(Autocreated.NOTATION[NotationType.LONG_INDEX].toUpperCase(),
+ Autocreated.NOTATION[NotationType.COMPRESSED_INDEX].toUpperCase(),
+ Autocreated.NOTATION[NotationType.COMPACT_INDEX].toUpperCase())) {
+ if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
+ childNodeDefn.changeState(ChildNodeDefinition.PropertyName.AUTOCREATED, Value.VARIANT);
+ } else {
+ childNodeDefn.changeState(ChildNodeDefinition.PropertyName.AUTOCREATED, Value.IS);
+ }
+ } else if (tokens.canConsumeAnyOf(Mandatory.NOTATION[NotationType.LONG_INDEX].toUpperCase(),
+ Mandatory.NOTATION[NotationType.COMPRESSED_INDEX].toUpperCase(),
+ Mandatory.NOTATION[NotationType.COMPACT_INDEX].toUpperCase())) {
+ if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
+ childNodeDefn.changeState(ChildNodeDefinition.PropertyName.MANDATORY, Value.VARIANT);
+ } else {
+ childNodeDefn.changeState(ChildNodeDefinition.PropertyName.MANDATORY, Value.IS);
+ }
+ } else if (tokens.canConsumeAnyOf(Protected.NOTATION[NotationType.LONG_INDEX].toUpperCase(),
+ Protected.NOTATION[NotationType.COMPRESSED_INDEX].toUpperCase(),
+ Protected.NOTATION[NotationType.COMPACT_INDEX].toUpperCase())) {
+ if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
+ childNodeDefn.changeState(ChildNodeDefinition.PropertyName.PROTECTED, Value.VARIANT);
+ } else {
+ childNodeDefn.changeState(ChildNodeDefinition.PropertyName.PROTECTED, Value.IS);
+ }
+ } else if (tokens.canConsumeAnyOf(SameNameSiblings.NOTATION[NotationType.LONG_INDEX].toUpperCase(),
+ SameNameSiblings.NOTATION[NotationType.COMPRESSED_INDEX].toUpperCase(),
+ SameNameSiblings.NOTATION[NotationType.COMPACT_INDEX].toUpperCase())) {
+ if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
+ childNodeDefn.changeState(ChildNodeDefinition.PropertyName.SAME_NAME_SIBLINGS, Value.VARIANT);
+ } else {
+ childNodeDefn.changeState(ChildNodeDefinition.PropertyName.SAME_NAME_SIBLINGS, Value.IS);
+ }
+ } else if (tokens.canConsumeAnyOf("MULTIPLE", "MUL", "*")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ // these keywords are no longer node attributes in JCR 2.0
+ if (!this.jcr170) {
+ final Position pos = tokens.previousPosition();
+ final int line = pos.getLine();
+ final int column = pos.getColumn();
+ throw new ParsingException(tokens.previousPosition(), NLS.bind(Messages.multipleKeywordNotValidInJcr2CndFormat,
+ line, column));
+ }
+
+ if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
+ childNodeDefn.changeState(ChildNodeDefinition.PropertyName.SAME_NAME_SIBLINGS, Value.VARIANT);
+ } else {
+ childNodeDefn.changeState(ChildNodeDefinition.PropertyName.SAME_NAME_SIBLINGS, Value.IS);
+ }
+ } else if (tokens.matchesAnyOf(Utils.toUpperCase(OnParentVersion.toArray()))) {
+ final String opv = tokens.consume();
+ childNodeDefn.setOnParentVersion(opv);
+ } else if (tokens.canConsumeAnyOf("PRIMARYITEM", "PRIMARY", "PRI", "!")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ if (!this.jcr170) {
+ final Position pos = tokens.previousPosition();
+ final int line = pos.getLine();
+ final int column = pos.getColumn();
+ throw new ParsingException(tokens.previousPosition(), NLS.bind(Messages.primaryKeywordNotValidInJcr2CndFormat,
+ line, column));
+ }
+
+ // Then this child node is considered the primary item ...
+ nodeTypeDefn.setPrimaryItemName(childNodeDefn.getName());
+ } else if (tokens.canConsumeAnyOf(PrimaryItem.NOTATION[NotationType.LONG_INDEX].toUpperCase(),
+ PrimaryItem.NOTATION[NotationType.COMPRESSED_INDEX].toUpperCase(),
+ PrimaryItem.NOTATION[NotationType.COMPACT_INDEX].toUpperCase())) {
+ // Then this child node is considered the primary item ...
+ nodeTypeDefn.setPrimaryItemName(childNodeDefn.getName());
+ } else {
+ break;
+ }
+ }
+ }
+
+ /**
* Parse the options for the node types, including whether the node type is orderable, a mixin, abstract, whether it supports
* querying, and which property/child node (if any) is the primary item for the node type.
*
@@ -296,8 +396,8 @@
* @param nodeTypeDefn the node type being created; may not be null
* @throws ParsingException if there is a problem parsing the content
*/
- private void parseNodeTypeAttributes( TokenStream tokens,
- NodeTypeDefinition nodeTypeDefn ) {
+ private void parseNodeTypeAttributes( final TokenStream tokens,
+ final NodeTypeDefinition nodeTypeDefn ) {
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
assert (nodeTypeDefn != null) : "nodeTypeDefn is null"; //$NON-NLS-1$
@@ -352,142 +452,57 @@
}
/**
- * Parse a node type's property or child node definitions that appear next on the token stream.
+ * Parse the node type definition that is next on the token stream.
*
- * @param tokens the tokens containing the definitions (cannot be <code>null</code>)
- * @param nodeTypeDefn the node type being created (cannot be <code>null</code>)
+ * @param tokens the tokens containing the node type definition (cannot be <code>null</code>)
+ * @param cnd the CND object representing the CND file being parsed (cannot be <code>null</code>)
* @throws ParsingException if there is a problem parsing the content
*/
- private void parsePropertyOrChildNodeDefinitions( TokenStream tokens,
- NodeTypeDefinition nodeTypeDefn ) {
+ private void parseNodeTypeDefinition( final TokenStream tokens,
+ final CompactNodeTypeDefinition cnd ) {
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
- assert (nodeTypeDefn != null) : "nodeTypeDefn is null"; //$NON-NLS-1$
+ assert (cnd != null) : "cnd is null"; //$NON-NLS-1$
- while (true) {
- // Keep reading while we see a property definition or child node definition ...
- if (tokens.matches(PropertyDefinition.NOTATION_PREFIX)) {
- parsePropertyDefinition(tokens, nodeTypeDefn);
- } else if (tokens.matches(ChildNodeDefinition.NOTATION_PREFIX)) {
- parseChildNodeDefinition(tokens, nodeTypeDefn);
- } else {
- // The next token does not signal either one of these, so stop ...
- break;
- }
- }
- }
+ final NodeTypeDefinition nodeType = new NodeTypeDefinition();
- /**
- * Parse a node type's property definition from the next tokens on the stream.
- *
- * @param tokens the tokens containing the definition (cannot be <code>null</code>)
- * @param nodeTypeDefn the node type definition (cannot be <code>null</code>)
- * @throws ParsingException if there is a problem parsing the content
- */
- private void parsePropertyDefinition( TokenStream tokens,
- NodeTypeDefinition nodeTypeDefn ) {
- assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
- assert (nodeTypeDefn != null) : "nodeTypeDefn is null"; //$NON-NLS-1$
-
- tokens.consume(PropertyDefinition.NOTATION_PREFIX);
- PropertyDefinition propDefn = new PropertyDefinition();
-
// name
- String name = parseName(tokens);
+ final String name = parseNodeTypeName(tokens);
if (!Utils.isEmpty(name)) {
- propDefn.setName(name);
+ nodeType.setName(name);
}
- // required type
- parsePropertyType(tokens, propDefn);
+ // supertypes
+ final List<String> superTypes = parseSupertypes(tokens);
- // Parse the default values ...
- parseDefaultValues(tokens, propDefn);
-
- // Parse the property attributes (and vendor extensions) ...
- parsePropertyAttributes(tokens, nodeTypeDefn, propDefn);
-
- // Parse the property constraints ...
- parseValueConstraints(tokens, propDefn);
-
- nodeTypeDefn.addPropertyDefinition(propDefn);
- }
-
- /**
- * Parse the property type, if a valid one appears next on the token stream.
- *
- * @param tokens the tokens containing the definition (cannot be <code>null</code>)
- * @param propDefn the property definition (cannot be <code>null</code>)
- * @throws ParsingException if there is a problem parsing the content
- */
- private void parsePropertyType( TokenStream tokens,
- PropertyDefinition propDefn ) {
- assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
- assert (propDefn != null) : "propDefn is null"; //$NON-NLS-1$
-
- if (tokens.canConsume(PropertyType.NOTATION_PREFIX)) {
- // Parse the (optional) property type ...
- if (tokens.matchesAnyOf(Utils.toUpperCase(PropertyType.validValues()))) {
- String propertyType = tokens.consume();
- propDefn.setType(PropertyType.find(propertyType));
+ if (!superTypes.isEmpty()) {
+ for (final String superType : superTypes) {
+ nodeType.addSuperType(superType);
}
-
- tokens.consume(PropertyType.NOTATION_SUFFIX);
}
- }
+ // Read the node type options (and vendor extensions) ...
+ parseNodeTypeAttributes(tokens, nodeType);
- /**
- * Parse the property definition's default values, if they appear next on the token stream.
- *
- * @param tokens the tokens containing the definition (cannot be <code>null</code>)
- * @param propDefn the property definition whose default values are being parsed (cannot be <code>null</code>)
- * @throws ParsingException if there is a problem parsing the content
- */
- private void parseDefaultValues( TokenStream tokens,
- PropertyDefinition propDefn ) {
- assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
- assert (propDefn != null) : "propDefn is null"; //$NON-NLS-1$
+ // Parse property and child node definitions ...
+ parsePropertyOrChildNodeDefinitions(tokens, nodeType);
- if (tokens.canConsume(DefaultValues.NOTATION_PREFIX)) {
- List<String> values = parseStringList(tokens);
-
- if (!values.isEmpty()) {
- if ((values.size() == 1) && AttributeState.VARIANT_STRING.equals(values.get(0))) {
- propDefn.changeState(PropertyDefinition.PropertyName.DEFAULT_VALUES, Value.VARIANT);
- } else {
- for (String value : values) {
- propDefn.addDefaultValue(value);
- }
- }
- }
- }
+ cnd.addNodeTypeDefinition(nodeType);
}
/**
- * Parse the property definition's value constraints, if they appear next on the token stream.
+ * Parse a node type name that appears next on the token stream.
*
- * @param tokens the tokens containing the definition (cannot be <code>null</code>)
- * @param propDefn the property definition whose value constraints are being parsed (cannot be <code>null</code>)
+ * @param tokens the tokens containing the node type name (cannot be <code>null</code>)
+ * @return the node type name
* @throws ParsingException if there is a problem parsing the content
*/
- private void parseValueConstraints( TokenStream tokens,
- PropertyDefinition propDefn ) {
+ private String parseNodeTypeName( final TokenStream tokens ) {
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
- assert (propDefn != null) : "propDefn is null"; //$NON-NLS-1$
- if (tokens.canConsume(ValueConstraints.NOTATION_PREFIX)) {
- List<String> constraints = parseStringList(tokens);
-
- if (!constraints.isEmpty()) {
- if ((constraints.size() == 1) && AttributeState.VARIANT_STRING.equals(constraints.get(0))) {
- propDefn.changeState(PropertyDefinition.PropertyName.VALUE_CONSTRAINTS, Value.VARIANT);
- } else {
- for (String constraint : constraints) {
- propDefn.addValueConstraint(constraint);
- }
- }
- }
- }
+ tokens.consume(NodeTypeDefinition.NAME_NOTATION_PREFIX);
+ final String name = parseName(tokens);
+ tokens.consume(NodeTypeDefinition.NAME_NOTATION_SUFFIX);
+ return name;
}
/**
@@ -498,9 +513,9 @@
* @param propDefn the property definition whose attributes are being parsed (cannot be <code>null</code>)
* @throws ParsingException if there is a problem parsing the content
*/
- private void parsePropertyAttributes( TokenStream tokens,
- NodeTypeDefinition nodeTypeDefn,
- PropertyDefinition propDefn ) {
+ private void parsePropertyAttributes( final TokenStream tokens,
+ final NodeTypeDefinition nodeTypeDefn,
+ final PropertyDefinition propDefn ) {
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
assert (propDefn != null) : "propDefn is null"; //$NON-NLS-1$
@@ -538,7 +553,7 @@
propDefn.changeState(PropertyDefinition.PropertyName.MULTIPLE, AttributeState.Value.IS);
}
} else if (tokens.matchesAnyOf(Utils.toUpperCase(OnParentVersion.toArray()))) {
- String opv = tokens.consume();
+ final String opv = tokens.consume();
propDefn.setOnParentVersion(opv);
} else if (tokens.canConsumeAnyOf(NoFullText.NOTATION[NotationType.LONG_INDEX].toUpperCase(),
NoFullText.NOTATION[NotationType.COMPRESSED_INDEX].toUpperCase(),
@@ -563,9 +578,9 @@
} else if (tokens.canConsumeAnyOf("PRIMARY", "PRI", "!")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// these keywords are no longer property attributes in JCR 2.0
if (!this.jcr170) {
- Position pos = tokens.previousPosition();
- int line = pos.getLine();
- int column = pos.getColumn();
+ final Position pos = tokens.previousPosition();
+ final int line = pos.getLine();
+ final int column = pos.getColumn();
throw new ParsingException(tokens.previousPosition(), NLS.bind(Messages.primaryKeywordNotValidInJcr2CndFormat,
line, column));
}
@@ -579,14 +594,99 @@
}
/**
+ * Parse a node type's property definition from the next tokens on the stream.
+ *
+ * @param tokens the tokens containing the definition (cannot be <code>null</code>)
+ * @param nodeTypeDefn the node type definition (cannot be <code>null</code>)
+ * @throws ParsingException if there is a problem parsing the content
+ */
+ private void parsePropertyDefinition( final TokenStream tokens,
+ final NodeTypeDefinition nodeTypeDefn ) {
+ assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
+ assert (nodeTypeDefn != null) : "nodeTypeDefn is null"; //$NON-NLS-1$
+
+ tokens.consume(PropertyDefinition.NOTATION_PREFIX);
+ final PropertyDefinition propDefn = new PropertyDefinition();
+
+ // name
+ final String name = parseName(tokens);
+
+ if (!Utils.isEmpty(name)) {
+ propDefn.setName(name);
+ }
+
+ // required type
+ parsePropertyType(tokens, propDefn);
+
+ // Parse the default values ...
+ parseDefaultValues(tokens, propDefn);
+
+ // Parse the property attributes (and vendor extensions) ...
+ parsePropertyAttributes(tokens, nodeTypeDefn, propDefn);
+
+ // Parse the property constraints ...
+ parseValueConstraints(tokens, propDefn);
+
+ nodeTypeDefn.addPropertyDefinition(propDefn);
+ }
+
+ /**
+ * Parse a node type's property or child node definitions that appear next on the token stream.
+ *
+ * @param tokens the tokens containing the definitions (cannot be <code>null</code>)
+ * @param nodeTypeDefn the node type being created (cannot be <code>null</code>)
+ * @throws ParsingException if there is a problem parsing the content
+ */
+ private void parsePropertyOrChildNodeDefinitions( final TokenStream tokens,
+ final NodeTypeDefinition nodeTypeDefn ) {
+ assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
+ assert (nodeTypeDefn != null) : "nodeTypeDefn is null"; //$NON-NLS-1$
+
+ while (true) {
+ // Keep reading while we see a property definition or child node definition ...
+ if (tokens.matches(PropertyDefinition.NOTATION_PREFIX)) {
+ parsePropertyDefinition(tokens, nodeTypeDefn);
+ } else if (tokens.matches(ChildNodeDefinition.NOTATION_PREFIX)) {
+ parseChildNodeDefinition(tokens, nodeTypeDefn);
+ } else {
+ // The next token does not signal either one of these, so stop ...
+ break;
+ }
+ }
+ }
+
+ /**
+ * Parse the property type, if a valid one appears next on the token stream.
+ *
+ * @param tokens the tokens containing the definition (cannot be <code>null</code>)
+ * @param propDefn the property definition (cannot be <code>null</code>)
+ * @throws ParsingException if there is a problem parsing the content
+ */
+ private void parsePropertyType( final TokenStream tokens,
+ final PropertyDefinition propDefn ) {
+ assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
+ assert (propDefn != null) : "propDefn is null"; //$NON-NLS-1$
+
+ if (tokens.canConsume(PropertyType.NOTATION_PREFIX)) {
+ // Parse the (optional) property type ...
+ if (tokens.matchesAnyOf(Utils.toUpperCase(PropertyType.validValues()))) {
+ final String propertyType = tokens.consume();
+ propDefn.setType(PropertyType.find(propertyType));
+ }
+
+ tokens.consume(PropertyType.NOTATION_SUFFIX);
+ }
+ }
+
+ /**
* Parse the property definition's query operators, if they appear next on the token stream.
*
* @param tokens the tokens containing the definition (cannot be <code>null</code>)
* @param propDefn the property definition whose query operators are being set (cannot be <code>null</code>)
* @throws ParsingException if there is a problem parsing the content
*/
- private void parseQueryOperators( TokenStream tokens,
- PropertyDefinition propDefn ) {
+ private void parseQueryOperators( final TokenStream tokens,
+ final PropertyDefinition propDefn ) {
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
assert (propDefn != null) : "propDefn is null"; //$NON-NLS-1$
@@ -594,17 +694,17 @@
propDefn.changeState(PropertyDefinition.PropertyName.QUERY_OPS, Value.VARIANT);
} else {
// The query operators are expected to be enclosed in a single quote, so therefore will be a single token ...
- String operatorList = removeQuotes(tokens.consume());
- List<String> operators = new ArrayList<String>();
+ final String operatorList = removeQuotes(tokens.consume());
+ final List<String> operators = new ArrayList<String>();
// Now split this string on ',' ...
- for (String operatorValue : operatorList.split(",")) { //$NON-NLS-1$
- QueryOperator operator = QueryOperator.find(operatorValue.trim());
+ for (final String operatorValue : operatorList.split(",")) { //$NON-NLS-1$
+ final QueryOperator operator = QueryOperator.find(operatorValue.trim());
if (operator != null) {
operators.add(operatorValue);
} else {
- throw new ParsingException(tokens.previousPosition(), NLS.bind(Messages.expectedValidQueryOperator, operator));
+ throw new ParsingException(tokens.previousPosition(), NLS.bind(Messages.invalidQueryOperator, operator));
}
}
@@ -615,60 +715,25 @@
}
/**
- * Parse a node type's child node definition from the next tokens on the stream.
- *
- * @param tokens the tokens containing the definition (cannot be <code>null</code>)
- * @param nodeTypeDefn the node type being created (cannot be <code>null</code>)
- * @throws ParsingException if there is a problem parsing the content
- */
- private void parseChildNodeDefinition( TokenStream tokens,
- NodeTypeDefinition nodeTypeDefn ) {
- assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
- assert (nodeTypeDefn != null) : "nodeTypeDefn is null"; //$NON-NLS-1$
-
- tokens.consume(ChildNodeDefinition.NOTATION_PREFIX);
- ChildNodeDefinition childNodeDefn = new ChildNodeDefinition();
-
- // name
- String name = parseName(tokens);
-
- if (!Utils.isEmpty(name)) {
- childNodeDefn.setName(name);
- }
-
- // required types
- parseRequiredPrimaryTypes(tokens, childNodeDefn);
-
- // default types
- parseDefaultType(tokens, childNodeDefn.getDefaultType());
-
- // attributes
- parseNodeAttributes(tokens, nodeTypeDefn, childNodeDefn);
-
- // add child node definition
- nodeTypeDefn.addChildNodeDefinition(childNodeDefn);
- }
-
- /**
* Parse the child node definition's list of required primary types, if they appear next on the token stream.
*
* @param tokens the tokens containing the definition (cannot be <code>null</code>)
* @param childNodeDefn the child node definition (cannot be <code>null</code>)
* @throws ParsingException if there is a problem parsing the content
*/
- private void parseRequiredPrimaryTypes( TokenStream tokens,
- ChildNodeDefinition childNodeDefn ) {
+ private void parseRequiredPrimaryTypes( final TokenStream tokens,
+ final ChildNodeDefinition childNodeDefn ) {
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
assert (childNodeDefn != null) : "childNodeDefn is null"; //$NON-NLS-1$
if (tokens.canConsume(RequiredTypes.NOTATION_PREFIX)) {
- List<String> requiredTypeNames = parseNameList(tokens);
+ final List<String> requiredTypeNames = parseNameList(tokens);
if (!requiredTypeNames.isEmpty()) {
if ((requiredTypeNames.size() == 1) && AttributeState.VARIANT_STRING.equals(requiredTypeNames.get(0))) {
childNodeDefn.changeState(ChildNodeDefinition.PropertyName.REQUIRED_TYPES, Value.VARIANT);
} else {
- for (String requiredTypeName : requiredTypeNames) {
+ for (final String requiredTypeName : requiredTypeNames) {
childNodeDefn.addRequiredType(requiredTypeName);
}
}
@@ -679,131 +744,76 @@
}
/**
- * Parse the child node definition's default type, if they appear next on the token stream.
+ * Parse a list of strings, separated by commas. Any quotes surrounding the strings are removed.
*
- * @param tokens the tokens containing the definition (cannot be <code>null</code>)
- * @param defaultType the default type (cannot be <code>null</code>)
+ * @param tokens the tokens containing the comma-separated strings (cannot be <code>null</code>)
+ * @return the list of string values (cannot be <code>null</code> but can be empty)
* @throws ParsingException if there is a problem parsing the content
*/
- private void parseDefaultType( TokenStream tokens,
- DefaultType defaultType ) {
+ private List<String> parseStringList( final TokenStream tokens ) {
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
- assert (defaultType != null) : "defaultType is null"; //$NON-NLS-1$
- if (tokens.canConsume(DefaultType.NOTATION)) {
- if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
- defaultType.set(Value.VARIANT);
- } else {
- String typeName = parseName(tokens);
+ final List<String> strings = new ArrayList<String>();
- if (!Utils.isEmpty(typeName)) {
- defaultType.setDefaultType(typeName);
- }
- }
+ if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
+ // This list is variant ...
+ strings.add(AttributeState.VARIANT_STRING);
+ } else {
+ // Read names until we see a ','
+ do {
+ strings.add(removeQuotes(tokens.consume()));
+ } while (tokens.canConsume(','));
}
+
+ return strings;
}
/**
- * Parse the child node definition's attributes, if they appear next on the token stream.
+ * Parse an optional list of supertypes if they appear next on the token stream.
*
- * @param tokens the tokens containing the attributes (cannot be <code>null</code>)
- * @param nodeTypeDefn the node type being created (cannot be <code>null</code>)
- * @param childDefn the child node definition (cannot be <code>null</code>)
+ * @param tokens the tokens containing the supertype names (cannot be <code>null</code>)
+ * @return the list of supertype names (cannot be <code>null</code> but can be empty)
* @throws ParsingException if there is a problem parsing the content
*/
- private void parseNodeAttributes( TokenStream tokens,
- NodeTypeDefinition nodeTypeDefn,
- ChildNodeDefinition childNodeDefn ) {
+ private List<String> parseSupertypes( final TokenStream tokens ) {
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
- assert (nodeTypeDefn != null) : "nodeTypeDefn is null"; //$NON-NLS-1$
- assert (childNodeDefn != null) : "childNodeDefn is null"; //$NON-NLS-1$
- while (true) {
- if (tokens.canConsumeAnyOf(Autocreated.NOTATION[NotationType.LONG_INDEX].toUpperCase(),
- Autocreated.NOTATION[NotationType.COMPRESSED_INDEX].toUpperCase(),
- Autocreated.NOTATION[NotationType.COMPACT_INDEX].toUpperCase())) {
- if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
- childNodeDefn.changeState(ChildNodeDefinition.PropertyName.AUTOCREATED, Value.VARIANT);
- } else {
- childNodeDefn.changeState(ChildNodeDefinition.PropertyName.AUTOCREATED, Value.IS);
- }
- } else if (tokens.canConsumeAnyOf(Mandatory.NOTATION[NotationType.LONG_INDEX].toUpperCase(),
- Mandatory.NOTATION[NotationType.COMPRESSED_INDEX].toUpperCase(),
- Mandatory.NOTATION[NotationType.COMPACT_INDEX].toUpperCase())) {
- if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
- childNodeDefn.changeState(ChildNodeDefinition.PropertyName.MANDATORY, Value.VARIANT);
- } else {
- childNodeDefn.changeState(ChildNodeDefinition.PropertyName.MANDATORY, Value.IS);
- }
- } else if (tokens.canConsumeAnyOf(Protected.NOTATION[NotationType.LONG_INDEX].toUpperCase(),
- Protected.NOTATION[NotationType.COMPRESSED_INDEX].toUpperCase(),
- Protected.NOTATION[NotationType.COMPACT_INDEX].toUpperCase())) {
- if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
- childNodeDefn.changeState(ChildNodeDefinition.PropertyName.PROTECTED, Value.VARIANT);
- } else {
- childNodeDefn.changeState(ChildNodeDefinition.PropertyName.PROTECTED, Value.IS);
- }
- } else if (tokens.canConsumeAnyOf(SameNameSiblings.NOTATION[NotationType.LONG_INDEX].toUpperCase(),
- SameNameSiblings.NOTATION[NotationType.COMPRESSED_INDEX].toUpperCase(),
- SameNameSiblings.NOTATION[NotationType.COMPACT_INDEX].toUpperCase())) {
- if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
- childNodeDefn.changeState(ChildNodeDefinition.PropertyName.SAME_NAME_SIBLINGS, Value.VARIANT);
- } else {
- childNodeDefn.changeState(ChildNodeDefinition.PropertyName.SAME_NAME_SIBLINGS, Value.IS);
- }
- } else if (tokens.canConsumeAnyOf("MULTIPLE", "MUL", "*")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- // these keywords are no longer node attributes in JCR 2.0
- if (!this.jcr170) {
- Position pos = tokens.previousPosition();
- int line = pos.getLine();
- int column = pos.getColumn();
- throw new ParsingException(tokens.previousPosition(), NLS.bind(Messages.multipleKeywordNotValidInJcr2CndFormat,
- line, column));
- }
+ if (tokens.canConsume(SuperTypes.NOTATION_PREFIX)) {
+ // There is at least one supertype ...
+ return parseNameList(tokens);
+ }
- if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
- childNodeDefn.changeState(ChildNodeDefinition.PropertyName.SAME_NAME_SIBLINGS, Value.VARIANT);
- } else {
- childNodeDefn.changeState(ChildNodeDefinition.PropertyName.SAME_NAME_SIBLINGS, Value.IS);
- }
- } else if (tokens.matchesAnyOf(Utils.toUpperCase(OnParentVersion.toArray()))) {
- String opv = tokens.consume();
- childNodeDefn.setOnParentVersion(opv);
- } else if (tokens.canConsumeAnyOf("PRIMARYITEM", "PRIMARY", "PRI", "!")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- if (!this.jcr170) {
- Position pos = tokens.previousPosition();
- int line = pos.getLine();
- int column = pos.getColumn();
- throw new ParsingException(tokens.previousPosition(), NLS.bind(Messages.primaryKeywordNotValidInJcr2CndFormat,
- line, column));
- }
-
- // Then this child node is considered the primary item ...
- nodeTypeDefn.setPrimaryItemName(childNodeDefn.getName());
- } else if (tokens.canConsumeAnyOf(PrimaryItem.NOTATION[NotationType.LONG_INDEX].toUpperCase(),
- PrimaryItem.NOTATION[NotationType.COMPRESSED_INDEX].toUpperCase(),
- PrimaryItem.NOTATION[NotationType.COMPACT_INDEX].toUpperCase())) {
- // Then this child node is considered the primary item ...
- nodeTypeDefn.setPrimaryItemName(childNodeDefn.getName());
- } else {
- break;
- }
- }
+ return Collections.emptyList();
}
/**
- * Parse the name that is expected to be next on the token stream.
+ * Parse the property definition's value constraints, if they appear next on the token stream.
*
- * @param tokens the tokens containing the name (cannot be <code>null</code>)
- * @return the name (cannot be <code>null</code>)
+ * @param tokens the tokens containing the definition (cannot be <code>null</code>)
+ * @param propDefn the property definition whose value constraints are being parsed (cannot be <code>null</code>)
* @throws ParsingException if there is a problem parsing the content
*/
- private String parseName( TokenStream tokens ) {
- String value = tokens.consume();
- return removeQuotes(value);
+ private void parseValueConstraints( final TokenStream tokens,
+ final PropertyDefinition propDefn ) {
+ assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
+ assert (propDefn != null) : "propDefn is null"; //$NON-NLS-1$
+
+ if (tokens.canConsume(ValueConstraints.NOTATION_PREFIX)) {
+ final List<String> constraints = parseStringList(tokens);
+
+ if (!constraints.isEmpty()) {
+ if ((constraints.size() == 1) && AttributeState.VARIANT_STRING.equals(constraints.get(0))) {
+ propDefn.changeState(PropertyDefinition.PropertyName.VALUE_CONSTRAINTS, Value.VARIANT);
+ } else {
+ for (final String constraint : constraints) {
+ propDefn.addValueConstraint(constraint);
+ }
+ }
+ }
+ }
}
- private final String removeQuotes( String text ) {
+ private final String removeQuotes( final String text ) {
// Remove leading and trailing quotes, if there are any ...
return text.replaceFirst("^['\"]+", "").replaceAll("['\"]+$", ""); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndNotationPreferences.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndNotationPreferences.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndNotationPreferences.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -19,9 +19,17 @@
*/
public class CndNotationPreferences {
+ /**
+ * All preferences used during CND notation construction.
+ */
public enum Preference {
/**
+ * The delimiter between list items.
+ */
+ ATTRIBUTE_LIST_ELEMENT_DELIMITER,
+
+ /**
* The delimiter after the prefix to attribute lists.
*/
ATTRIBUTE_LIST_PREFIX_END_DELIMITER,
@@ -151,6 +159,7 @@
private void loadDefaults( Map<Preference, String> map ) {
assert (map != null) : "preference map is null"; //$NON-NLS-1$
+ map.put(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER, ", "); //$NON-NLS-1$
map.put(Preference.CHILD_NODE_DEFINITION_DELIMITER, "\n"); //$NON-NLS-1$
map.put(Preference.CHILD_NODE_PROPERTY_DELIMITER, "\n"); //$NON-NLS-1$
map.put(Preference.CHILD_NODE_DEFINITION_SECTION_END_DELIMITER, "\n"); //$NON-NLS-1$
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndTokenizer.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndTokenizer.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndTokenizer.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -56,13 +56,18 @@
*/
public static final int VENDOR_EXTENSION = 7;
- private final boolean useComments;
- private final boolean useVendorExtensions;
+ private final boolean useComments = false;
+ private final boolean useVendorExtensions = false;
+ /**
+ * <strong>Currently comments and vendor extensions are not supported by the framework.</strong>
+ * @param useComments a flag indicating if comments should be used
+ * @param useVendorExtensions a flag indicating if vendor extensions should be used
+ */
public CndTokenizer( boolean useComments,
boolean useVendorExtensions ) {
- this.useComments = useComments;
- this.useVendorExtensions = useVendorExtensions;
+// this.useComments = useComments;
+// this.useVendorExtensions = useVendorExtensions;
}
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -23,41 +23,19 @@
import org.jboss.tools.modeshape.jcr.cnd.attributes.QueryOperators.QueryOperator;
/**
- *
+ * Used to validate values stored in a CND.
*/
public final class CndValidator {
- public static ValidationStatus validateUri( String uri,
- String propertyName ) {
- Utils.verifyIsNotEmpty(propertyName, "propertyName"); //$NON-NLS-1$
-
- if (Utils.isEmpty(uri) || uri.contains(" ")) { //$NON-NLS-1$
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyValue, propertyName));
- }
-
- try {
- URI.create(uri);
- } catch (Exception e) {
- return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidUri, propertyName));
- }
-
- return ValidationStatus.OK_STATUS;
- }
-
- public static void isValid( String value,
- PropertyType propertyType,
- String propertyName,
- MultiValidationStatus status ) {
- ValidationStatus newStatus = isValid(value, propertyType, propertyName);
-
- if (!newStatus.isOk()) {
- status.add(newStatus);
- }
- }
-
- public static ValidationStatus isValid( String value,
- PropertyType propertyType,
- String propertyName ) {
+ /**
+ * @param value the value being checked (can be <code>null</code> or empty)
+ * @param propertyType the property type of the property definition the value is for (cannot be <code>null</code>)
+ * @param propertyName the name to use to identify the property definition (cannot be <code>null</code> empty)
+ * @return the status (never <code>null</code>)
+ */
+ public static ValidationStatus isValid( final String value,
+ final PropertyType propertyType,
+ final String propertyName ) {
Utils.isNotNull(propertyType, "propertyType"); //$NON-NLS-1$
if (Utils.isEmpty(value)) {
@@ -79,28 +57,28 @@
} else if (PropertyType.DATE == propertyType) {
try {
Date.valueOf(value);
- } catch (Exception e) {
+ } catch (final Exception e) {
return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, new Object[] { value,
PropertyType.DATE, propertyName }));
}
} else if (PropertyType.DECIMAL == propertyType) {
try {
new BigDecimal(value);
- } catch (Exception e) {
+ } catch (final Exception e) {
return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, value,
PropertyType.DECIMAL));
}
} else if (PropertyType.DOUBLE == propertyType) {
try {
Double.parseDouble(value);
- } catch (Exception e) {
+ } catch (final Exception e) {
return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, value,
PropertyType.DOUBLE));
}
} else if (PropertyType.LONG == propertyType) {
try {
Long.parseLong(value);
- } catch (Exception e) {
+ } catch (final Exception e) {
return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, value,
PropertyType.LONG));
}
@@ -119,12 +97,33 @@
}
return ValidationStatus.OK_STATUS;
- } catch (Exception e) {
+ } catch (final Exception e) {
return ValidationStatus.createErrorMessage(NLS.bind(Messages.errorValidatingPropertyValueForType, new Object[] { value,
propertyType, propertyName }));
}
}
+ /**
+ * @param value the value being checked (can be <code>null</code> or empty)
+ * @param propertyType the property type of the property definition the value is for (cannot be <code>null</code>)
+ * @param propertyName the name to use to identify the property definition (cannot be <code>null</code> empty)
+ * @param status the status to add the new status to (never <code>null</code>)
+ */
+ public static void isValid( final String value,
+ final PropertyType propertyType,
+ final String propertyName,
+ final MultiValidationStatus status ) {
+ final ValidationStatus newStatus = isValid(value, propertyType, propertyName);
+
+ if (!newStatus.isOk()) {
+ status.add(newStatus);
+ }
+ }
+
+ /**
+ * @param childNodeDefinition the child node definition being validated (cannot be <code>null</code>)
+ * @return the status (never <code>null</code>)
+ */
public static ValidationStatus validateChildNodeDefinition( final ChildNodeDefinition childNodeDefinition ) {
Utils.isNotNull(childNodeDefinition, "childNodeDefinition"); //$NON-NLS-1$
@@ -161,7 +160,7 @@
} else {
final List<String> names = new ArrayList<String>(requiredTypeNames.length);
- for (String requiredTypeName : requiredTypeNames) {
+ for (final String requiredTypeName : requiredTypeNames) {
// ERROR - Invalid required type name
validateLocalName(requiredTypeName, Messages.requiredTypeName, status);
@@ -199,6 +198,10 @@
return status;
}
+ /**
+ * @param childNodeDefinition the child node definition being validated (cannot be <code>null</code>)
+ * @param status the status to add the new status to (never <code>null</code>)
+ */
public static void validateChildNodeDefinition( final ChildNodeDefinition childNodeDefinition,
final MultiValidationStatus status ) {
final ValidationStatus newStatus = validateChildNodeDefinition(childNodeDefinition);
@@ -208,6 +211,10 @@
}
}
+ /**
+ * @param cnd the CND being validated (cannot be <code>null</code>)
+ * @return the status (never <code>null</code>)
+ */
public static ValidationStatus validateCnd( final CompactNodeTypeDefinition cnd ) {
Utils.isNotNull(cnd, "cnd"); //$NON-NLS-1$
@@ -249,6 +256,10 @@
return status;
}
+ /**
+ * @param cnd the CND being validated (cannot be <code>null</code>)
+ * @param status the status to add the new status to (never <code>null</code>)
+ */
public static void validateCnd( final CompactNodeTypeDefinition cnd,
final MultiValidationStatus status ) {
final ValidationStatus newStatus = validateCnd(cnd);
@@ -258,6 +269,11 @@
}
}
+ /**
+ * @param localName the local name being validated (cannot be <code>null</code>)
+ * @param propertyName the name to use in the validation message (cannot be <code>null</code>)
+ * @return the status (never <code>null</code>)
+ */
public static ValidationStatus validateLocalName( final String localName,
final String propertyName ) {
Utils.verifyIsNotEmpty(propertyName, propertyName);
@@ -271,7 +287,7 @@
return ValidationStatus.createErrorMessage(NLS.bind(Messages.localNameEqualToSelfOrParent, propertyName));
}
- for (char c : localName.toCharArray()) {
+ for (final char c : localName.toCharArray()) {
switch (c) {
case '/':
case ':':
@@ -289,6 +305,11 @@
return ValidationStatus.OK_STATUS;
}
+ /**
+ * @param localName the local name being validated (cannot be <code>null</code>)
+ * @param propertyName the name to use in the validation message (cannot be <code>null</code>)
+ * @param status the status to add the new status to (never <code>null</code>)
+ */
public static void validateLocalName( final String localName,
final String propertyName,
final MultiValidationStatus status ) {
@@ -299,6 +320,10 @@
}
}
+ /**
+ * @param namespaceMapping the namespace mapping being validated (cannot be <code>null</code>)
+ * @return the status (never <code>null</code>)
+ */
public static ValidationStatus validateNamespaceMapping( final NamespaceMapping namespaceMapping ) {
Utils.isNotNull(namespaceMapping, "namespaceMapping"); //$NON-NLS-1$
@@ -320,6 +345,10 @@
return status;
}
+ /**
+ * @param namespaceMapping the namespace mapping being validated (cannot be <code>null</code>)
+ * @param status the status to add the new status to (never <code>null</code>)
+ */
public static void validateNamespaceMapping( final NamespaceMapping namespaceMapping,
final MultiValidationStatus status ) {
final ValidationStatus newStatus = validateNamespaceMapping(namespaceMapping);
@@ -329,6 +358,10 @@
}
}
+ /**
+ * @param namespaceMappings the collection of namespace mappings being validated (can be <code>null</code> or empty)
+ * @return the status (never <code>null</code>)
+ */
public static MultiValidationStatus validateNamespaceMappings( final List<NamespaceMapping> namespaceMappings ) {
/**
* <pre>
@@ -347,7 +380,7 @@
final List<String> prefixes = new ArrayList<String>(namespaceMappings.size());
final List<String> uris = new ArrayList<String>(namespaceMappings.size());
- for (NamespaceMapping namespaceMapping : namespaceMappings) {
+ for (final NamespaceMapping namespaceMapping : namespaceMappings) {
validateNamespaceMapping(namespaceMapping, status);
{ // ERROR - Duplicate namespace mapping prefix
@@ -378,6 +411,10 @@
return status;
}
+ /**
+ * @param namespaceMappings the collection of namespace mappings being validated (can be <code>null</code> or empty)
+ * @param status the status to add the new status to (never <code>null</code>)
+ */
public static void validateNamespaceMappings( final List<NamespaceMapping> namespaceMappings,
final MultiValidationStatus status ) {
final ValidationStatus newStatus = validateNamespaceMappings(namespaceMappings);
@@ -387,6 +424,10 @@
}
}
+ /**
+ * @param nodeTypeDefinition the node type definition being validated (cannot be <code>null</code>)
+ * @return the status (never <code>null</code>)
+ */
public static ValidationStatus validateNodeTypeDefinition( final NodeTypeDefinition nodeTypeDefinition ) {
Utils.isNotNull(nodeTypeDefinition, "nodeTypeDefinition"); //$NON-NLS-1$
@@ -426,7 +467,7 @@
} else {
final List<String> names = new ArrayList<String>(superTypeNames.length);
- for (String superTypeName : superTypeNames) {
+ for (final String superTypeName : superTypeNames) {
// ERROR - Invalid super type name
validateLocalName(superTypeName, Messages.superTypeName, status);
@@ -450,7 +491,7 @@
}
{ // primary item
- String primaryItemName = nodeTypeDefinition.getPrimaryItemName();
+ final String primaryItemName = nodeTypeDefinition.getPrimaryItemName();
if (nodeTypeDefinition.getState(NodeTypeDefinition.PropertyName.PRIMARY_ITEM) == Value.IS) {
// ERROR - Empty or invalid primary item name
@@ -473,7 +514,7 @@
} else {
final List<String> propNames = new ArrayList<String>(propertyDefinitions.size());
- for (PropertyDefinition propertyDefn : propertyDefinitions) {
+ for (final PropertyDefinition propertyDefn : propertyDefinitions) {
validatePropertyDefinition(propertyDefn, status);
{ // ERROR - Duplicate property definition names
@@ -500,7 +541,7 @@
} else {
final List<String> childNodeNames = new ArrayList<String>(childNodeDefinitions.size());
- for (ChildNodeDefinition childNodeDefn : childNodeDefinitions) {
+ for (final ChildNodeDefinition childNodeDefn : childNodeDefinitions) {
validateChildNodeDefinition(childNodeDefn, status);
{ // ERROR - Duplicate child node definition names
@@ -527,6 +568,10 @@
return status;
}
+ /**
+ * @param nodeTypeDefinition the node type definition being validated (cannot be <code>null</code>)
+ * @param status the status to add the new status to (never <code>null</code>)
+ */
public static void validateNodeTypeDefinition( final NodeTypeDefinition nodeTypeDefinition,
final MultiValidationStatus status ) {
final ValidationStatus newStatus = validateNodeTypeDefinition(nodeTypeDefinition);
@@ -536,6 +581,10 @@
}
}
+ /**
+ * @param nodeTypeDefinitions the collection of namespace mappings to validate (can be <code>null</code> or empty)
+ * @return the status (never <code>null</code>)
+ */
public static ValidationStatus validateNodeTypeDefinitions( final List<NodeTypeDefinition> nodeTypeDefinitions ) {
/**
* <pre>
@@ -552,7 +601,7 @@
final List<String> names = new ArrayList<String>(nodeTypeDefinitions.size());
- for (NodeTypeDefinition nodeTypeDefinition : nodeTypeDefinitions) {
+ for (final NodeTypeDefinition nodeTypeDefinition : nodeTypeDefinitions) {
validateNodeTypeDefinition(nodeTypeDefinition, status);
{ // ERROR - Duplicate node type definition names
@@ -571,6 +620,10 @@
return status;
}
+ /**
+ * @param nodeTypeDefinitions the collection of namespace mappings to validate (can be <code>null</code> or empty)
+ * @param status the status to add the new status to (never <code>null</code>)
+ */
public static void validateNodeTypeDefinitions( final List<NodeTypeDefinition> nodeTypeDefinitions,
final MultiValidationStatus status ) {
final ValidationStatus newStatus = validateNodeTypeDefinitions(nodeTypeDefinitions);
@@ -580,7 +633,11 @@
}
}
- public static ValidationStatus validatePropertyDefinition( PropertyDefinition propertyDefinition ) {
+ /**
+ * @param propertyDefinition the property definition being validated (never <code>null</code>)
+ * @return the status (never <code>null</code>)
+ */
+ public static ValidationStatus validatePropertyDefinition( final PropertyDefinition propertyDefinition ) {
Utils.isNotNull(propertyDefinition, "propertyDefinition"); //$NON-NLS-1$
/**
@@ -618,7 +675,7 @@
}
{ // default values
- List<String> defaultValues = propertyDefinition.getDefaultValuesAsStrings();
+ final List<String> defaultValues = propertyDefinition.getDefaultValuesAsStrings();
if (Utils.isEmpty(defaultValues)) {
if (propertyDefinition.getState(PropertyDefinition.PropertyName.DEFAULT_VALUES) == Value.IS) {
@@ -634,7 +691,7 @@
final List<String> values = new ArrayList<String>(defaultValues.size());
- for (String defaultValue : defaultValues) {
+ for (final String defaultValue : defaultValues) {
// ERROR - Default value is not valid for the property definition type
isValid(defaultValue, propertyDefinition.getType(), Messages.defaultValue, status);
@@ -658,7 +715,7 @@
}
{ // value constraints
- String[] valueConstraints = propertyDefinition.getValueConstraints();
+ final String[] valueConstraints = propertyDefinition.getValueConstraints();
if (Utils.isEmpty(valueConstraints)) {
if (propertyDefinition.getState(PropertyDefinition.PropertyName.VALUE_CONSTRAINTS) == Value.IS) {
@@ -667,7 +724,7 @@
} else {
final List<String> constraints = new ArrayList<String>(valueConstraints.length);
- for (String constraint : valueConstraints) {
+ for (final String constraint : valueConstraints) {
// ERROR - Invalid value constraint
validateValueConstraint(constraint, status);
@@ -691,7 +748,7 @@
}
{ // query operators
- String[] queryOperators = propertyDefinition.getAvailableQueryOperators();
+ final String[] queryOperators = propertyDefinition.getAvailableQueryOperators();
if (Utils.isEmpty(queryOperators)) {
if (propertyDefinition.getState(PropertyDefinition.PropertyName.QUERY_OPS) == Value.IS) {
@@ -700,7 +757,7 @@
} else {
final List<String> operators = new ArrayList<String>(queryOperators.length);
- for (String operator : queryOperators) {
+ for (final String operator : queryOperators) {
// ERROR - Invalid query operator
validateQueryOperator(operator, status);
@@ -726,47 +783,89 @@
return status;
}
- public static ValidationStatus validateQueryOperator( String operator ) {
- if (Utils.isEmpty(operator)) {
- return ValidationStatus.createErrorMessage(Messages.emptyQueryOperator);
+ /**
+ * @param propertyDefinition the property definition being validated (never <code>null</code>)
+ * @param status the status to add the new status to (never <code>null</code>)
+ */
+ public static void validatePropertyDefinition( final PropertyDefinition propertyDefinition,
+ final MultiValidationStatus status ) {
+ final ValidationStatus newStatus = validatePropertyDefinition(propertyDefinition);
+
+ if (!newStatus.isOk()) {
+ status.add(newStatus);
}
+ }
+ /**
+ * @param operator the query operator being validated (can be <code>null</code> or empty)
+ * @return the status (never <code>null</code>)
+ */
+ public static ValidationStatus validateQueryOperator( final String operator ) {
+ Utils.verifyIsNotEmpty(operator, "operator"); //$NON-NLS-1$
+
try {
QueryOperator.find(operator);
- } catch (Exception e) {
+ } catch (final Exception e) {
return ValidationStatus.createErrorMessage(Messages.invalidQueryOperator);
}
return ValidationStatus.OK_STATUS;
}
- public static void validateQueryOperator( String operator,
- MultiValidationStatus status ) {
- ValidationStatus newStatus = validateQueryOperator(operator);
+ /**
+ * @param operator the query operator being validated (can be <code>null</code> or empty)
+ * @param status the status to add the new status to (never <code>null</code>)
+ */
+ public static void validateQueryOperator( final String operator,
+ final MultiValidationStatus status ) {
+ final ValidationStatus newStatus = validateQueryOperator(operator);
if (!newStatus.isOk()) {
status.add(newStatus);
}
}
- public static ValidationStatus validateValueConstraint( String constraint ) {
- // TODO implement
- return null;
- }
+ /**
+ * @param uri the URI being checked (can be <code>null</code> or empty)
+ * @param propertyName the name to use to identify the URI (cannot be <code>null</code> empty)
+ * @return the status (never <code>null</code>)
+ */
+ public static ValidationStatus validateUri( final String uri,
+ final String propertyName ) {
+ Utils.verifyIsNotEmpty(propertyName, "propertyName"); //$NON-NLS-1$
- public static void validateValueConstraint( String constraint,
- MultiValidationStatus status ) {
- ValidationStatus newStatus = validateValueConstraint(constraint);
+ if (Utils.isEmpty(uri) || uri.contains(" ")) { //$NON-NLS-1$
+ return ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyValue, propertyName));
+ }
- if (!newStatus.isOk()) {
- status.add(newStatus);
+ try {
+ URI.create(uri);
+ } catch (final Exception e) {
+ return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidUri, propertyName));
}
+
+ return ValidationStatus.OK_STATUS;
}
- public static void validatePropertyDefinition( PropertyDefinition propertyDefinition,
- MultiValidationStatus status ) {
- ValidationStatus newStatus = validatePropertyDefinition(propertyDefinition);
+ /**
+ * @param constraint the value constraint being validated (cannot be <code>null</code> or empty)
+ * @return the status (never <code>null</code>)
+ */
+ public static ValidationStatus validateValueConstraint( final String constraint ) {
+ Utils.verifyIsNotEmpty(constraint, "constraint"); //$NON-NLS-1$
+ // TODO implement
+ return null;
+ }
+
+ /**
+ * @param constraint the value constraint being validated (cannot be <code>null</code> or empty)
+ * @param status the status to add the new status to (never <code>null</code>)
+ */
+ public static void validateValueConstraint( final String constraint,
+ final MultiValidationStatus status ) {
+ final ValidationStatus newStatus = validateValueConstraint(constraint);
+
if (!newStatus.isOk()) {
status.add(newStatus);
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/LocalName.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/LocalName.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/LocalName.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -14,40 +14,6 @@
*/
public class LocalName implements CndElement {
- public enum Mode {
-
- /**
- * The name is not surrounded by quotes in the CND notation.
- */
- UNQOUTED(Utils.EMPTY_STRING),
-
- /**
- * The name is surrounded by single quotes in the CND notation.
- */
- SINGLE_QUOTED("'"), //$NON-NLS-1$
-
- /**
- * The name is surrounded by double quotes in the CND notation.
- */
- DOUBLE_QUOTED("\""); //$NON-NLS-1$
-
- private final String delim;
-
- private Mode( String delim ) {
- this.delim = delim;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Enum#toString()
- */
- @Override
- public String toString() {
- return this.delim;
- }
- }
-
private Mode mode = Mode.UNQOUTED;
private String value;
@@ -62,7 +28,7 @@
/**
* @param initialValue the initial name value (can be <code>null</code> or empty)
*/
- public LocalName( String initialValue ) {
+ public LocalName( final String initialValue ) {
this.value = initialValue;
}
@@ -72,7 +38,7 @@
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals( Object obj ) {
+ public boolean equals( final Object obj ) {
if (this == obj) {
return true;
}
@@ -81,7 +47,7 @@
return false;
}
- LocalName that = (LocalName)obj;
+ final LocalName that = (LocalName)obj;
return Utils.equals(this.value, that.value);
}
@@ -144,7 +110,7 @@
* @param newMode the new mode (cannot be <code>null</code>)
* @return <code>true</code> if the model was changed
*/
- public boolean setMode( Mode newMode ) {
+ public boolean setMode( final Mode newMode ) {
Utils.isNotNull(newMode, "newMode"); //$NON-NLS-1$
if (this.mode != newMode) {
@@ -161,8 +127,8 @@
* @see org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- public String toCndNotation( NotationType notationType ) {
- StringBuilder builder = new StringBuilder();
+ public String toCndNotation( final NotationType notationType ) {
+ final StringBuilder builder = new StringBuilder();
Mode notationMode = this.mode;
if (!Utils.isEmpty(this.value) && this.value.contains(" ") && (this.mode == Mode.UNQOUTED)) { //$NON-NLS-1$
@@ -176,4 +142,41 @@
return builder.toString();
}
+ /**
+ * The quotation preference when using the name in CND notation.
+ */
+ public enum Mode {
+
+ /**
+ * The name is not surrounded by quotes in the CND notation.
+ */
+ UNQOUTED(Utils.EMPTY_STRING),
+
+ /**
+ * The name is surrounded by single quotes in the CND notation.
+ */
+ SINGLE_QUOTED("'"), //$NON-NLS-1$
+
+ /**
+ * The name is surrounded by double quotes in the CND notation.
+ */
+ DOUBLE_QUOTED("\""); //$NON-NLS-1$
+
+ private final String delim;
+
+ private Mode( final String delim ) {
+ this.delim = delim;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Enum#toString()
+ */
+ @Override
+ public String toString() {
+ return this.delim;
+ }
+ }
+
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinition.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinition.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinition.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -29,62 +29,11 @@
import org.jboss.tools.modeshape.jcr.cnd.attributes.SuperTypes;
/**
- *
+ * Represents a CND node type definition.
*/
public class NodeTypeDefinition implements CndElement, NodeTypeTemplate {
/**
- * The property names whose <code>toString()</code> is used in {@link PropertyChangeEvent}s.
- */
- public enum PropertyName {
-
- /**
- * The abstract attribute.
- */
- ABSTRACT,
-
- /**
- * The collection for child node definitions.
- */
- CHILD_NODES,
-
- /**
- * The mixin attribute.
- */
- MIXIN,
-
- /**
- * The node type name.
- */
- NAME,
-
- /**
- * The orderable attribute.
- */
- ORDERABLE,
-
- /**
- * The primary item attribute.
- */
- PRIMARY_ITEM,
-
- /**
- * The collection of property definitions.
- */
- PROPERTY_DEFINITIONS,
-
- /**
- * The queryable attribute.
- */
- QUERYABLE,
-
- /**
- * The collection for super types.
- */
- SUPERTYPES
- }
-
- /**
* Then node type name prefix used in the CND notation.
*/
public static final String NAME_NOTATION_PREFIX = "["; //$NON-NLS-1$
@@ -124,6 +73,9 @@
*/
private final SuperTypes superTypes;
+ /**
+ * Constructs a node type definition having default values for all attributes and properties.
+ */
public NodeTypeDefinition() {
this.attributes = new NodeTypeAttributes();
this.name = new LocalName();
@@ -137,7 +89,7 @@
* @param childNodeDefinitionBeingAdded the child node definition being added (cannot be <code>null</code>)
* @return <code>true</code> if successfully added
*/
- public boolean addChildNodeDefinition( ChildNodeDefinition childNodeDefinitionBeingAdded ) {
+ public boolean addChildNodeDefinition( final ChildNodeDefinition childNodeDefinitionBeingAdded ) {
Utils.isNotNull(childNodeDefinitionBeingAdded, "childNodeDefinitionBeingAdded"); //$NON-NLS-1$
if (this.childNodesDefinitions == null) {
@@ -156,7 +108,7 @@
* @param newListener the listener being added (cannot be <code>null</code>)
* @return <code>true</code> if successfully added
*/
- public boolean addListener( PropertyChangeListener newListener ) {
+ public boolean addListener( final PropertyChangeListener newListener ) {
Utils.isNotNull(newListener, "newListener"); //$NON-NLS-1$
return this.listeners.addIfAbsent(newListener);
}
@@ -167,7 +119,7 @@
* @param properyDefinitionBeingAdded the property definition being added (cannot be <code>null</code>)
* @return <code>true</code> if successfully added
*/
- public boolean addPropertyDefinition( PropertyDefinition properyDefinitionBeingAdded ) {
+ public boolean addPropertyDefinition( final PropertyDefinition properyDefinitionBeingAdded ) {
Utils.isNotNull(properyDefinitionBeingAdded, "properyDefinitionBeingAdded"); //$NON-NLS-1$
if (this.propertyDefinitions == null) {
@@ -188,7 +140,7 @@
* @param superTypeBeingAdded the super type name being added (cannot be <code>null</code> or empty)
* @return <code>true</code> if successfully added
*/
- public boolean addSuperType( String superTypeBeingAdded ) {
+ public boolean addSuperType( final String superTypeBeingAdded ) {
Utils.verifyIsNotEmpty(superTypeBeingAdded, "superTypeBeingAdded"); //$NON-NLS-1$
if (this.superTypes.add(superTypeBeingAdded)) {
@@ -207,13 +159,13 @@
* @param newState the new state (cannot be <code>null</code>)
* @return <code>true</code> if the attribute state was changed
*/
- public boolean changeState( PropertyName propertyName,
- Value newState ) {
+ public boolean changeState( final PropertyName propertyName,
+ final Value newState ) {
Utils.isNotNull(propertyName, "propertyName"); //$NON-NLS-1$
Utils.isNotNull(newState, "newState"); //$NON-NLS-1$
Object oldValue = null;
- Object newValue = newState;
+ final Object newValue = newState;
boolean changed = false;
if (PropertyName.ABSTRACT == propertyName) {
@@ -254,8 +206,8 @@
return false; // nothing to clear
}
- List<ChildNodeDefinition> childNodes = new ArrayList<ChildNodeDefinition>(getChildNodeDefinitions());
- boolean cleared = !this.childNodesDefinitions.isEmpty();
+ final List<ChildNodeDefinition> childNodes = new ArrayList<ChildNodeDefinition>(getChildNodeDefinitions());
+ final boolean cleared = !this.childNodesDefinitions.isEmpty();
this.childNodesDefinitions = null;
if (cleared) {
@@ -275,8 +227,8 @@
return false; // nothing to clear
}
- List<PropertyDefinition> propDefns = new ArrayList<PropertyDefinition>(getPropertyDefinitions());
- boolean cleared = !this.propertyDefinitions.isEmpty();
+ final List<PropertyDefinition> propDefns = new ArrayList<PropertyDefinition>(getPropertyDefinitions());
+ final boolean cleared = !this.propertyDefinitions.isEmpty();
this.propertyDefinitions = null;
if (cleared) {
@@ -292,7 +244,7 @@
* @return <code>true</code> if there was at least one super type before clearing
*/
public boolean clearSuperTypes() {
- List<String> types = new ArrayList<String>(this.superTypes.getSupportedItems());
+ final List<String> types = new ArrayList<String>(this.superTypes.getSupportedItems());
if (this.superTypes.clear()) {
notifyChangeListeners(PropertyName.SUPERTYPES, types, null);
@@ -324,7 +276,7 @@
*/
@Override
public NodeDefinition[] getDeclaredChildNodeDefinitions() {
- List<ChildNodeDefinition> childNodes = getChildNodeDefinitions();
+ final List<ChildNodeDefinition> childNodes = getChildNodeDefinitions();
return childNodes.toArray(new NodeDefinition[childNodes.size()]);
}
@@ -335,7 +287,7 @@
*/
@Override
public PropertyDefinition[] getDeclaredPropertyDefinitions() {
- List<PropertyDefinition> propDefns = getPropertyDefinitions();
+ final List<PropertyDefinition> propDefns = getPropertyDefinitions();
return propDefns.toArray(new PropertyDefinition[propDefns.size()]);
}
@@ -396,7 +348,7 @@
*/
@Override
public String getPrimaryItemName() {
- String primaryItem = this.attributes.getPrimaryItem().getPrimaryItem();
+ final String primaryItem = this.attributes.getPrimaryItem().getPrimaryItem();
// API states to return null
if (Utils.isEmpty(primaryItem)) {
@@ -439,7 +391,7 @@
* @return the attribute state (never <code>null</code>)
* @throws IllegalArgumentException if a property that does not have an attribute state is specified
*/
- public Value getState( PropertyName propertyName ) {
+ public Value getState( final PropertyName propertyName ) {
Utils.isNotNull(propertyName, "propertyName"); //$NON-NLS-1$
if (PropertyName.ABSTRACT == propertyName) {
@@ -513,7 +465,7 @@
* @param propertyName the property being checked (cannot be <code>null</code>)
* @return <code>true</code> if property is a variant
*/
- public boolean isVariant( PropertyName propertyName ) {
+ public boolean isVariant( final PropertyName propertyName ) {
Utils.isNotNull(propertyName, "propertyName"); //$NON-NLS-1$
return (getState(propertyName) == Value.VARIANT);
}
@@ -526,12 +478,12 @@
private void notifyChangeListeners( final PropertyName property,
final Object oldValue,
final Object newValue ) {
- PropertyChangeEvent event = new PropertyChangeEvent(this, property.toString(), oldValue, newValue);
+ final PropertyChangeEvent event = new PropertyChangeEvent(this, property.toString(), oldValue, newValue);
for (final Object listener : this.listeners.toArray()) {
try {
((PropertyChangeListener)listener).propertyChange(event);
- } catch (Exception e) {
+ } catch (final Exception e) {
// TODO log this
this.listeners.remove(listener);
}
@@ -544,7 +496,7 @@
* @param childNodeDefinitionBeingRemoved the child node definition being removed (cannot be <code>null</code>)
* @return <code>true</code> if successfully removed
*/
- public boolean removeChildNodeDefinition( ChildNodeDefinition childNodeDefinitionBeingRemoved ) {
+ public boolean removeChildNodeDefinition( final ChildNodeDefinition childNodeDefinitionBeingRemoved ) {
Utils.isNotNull(childNodeDefinitionBeingRemoved, "childNodeDefinitionBeingRemoved"); //$NON-NLS-1$
if (this.childNodesDefinitions == null) {
@@ -568,7 +520,7 @@
* @param listener the listener who no longer will receive property change events (cannot be <code>null</code>)
* @return <code>true</code> if successfully removed
*/
- public boolean removeListener( PropertyChangeListener listener ) {
+ public boolean removeListener( final PropertyChangeListener listener ) {
Utils.isNotNull(listener, "listener"); //$NON-NLS-1$
return this.listeners.remove(listener);
}
@@ -579,7 +531,7 @@
* @param propertyDefinitionBeingRemoved the property definition being removed (cannot be <code>null</code>)
* @return <code>true</code> if successfully removed
*/
- public boolean removePropertyDefinition( PropertyDefinition propertyDefinitionBeingRemoved ) {
+ public boolean removePropertyDefinition( final PropertyDefinition propertyDefinitionBeingRemoved ) {
Utils.isNotNull(propertyDefinitionBeingRemoved, "propertyDefinitionBeingRemoved"); //$NON-NLS-1$
if (this.propertyDefinitions == null) {
@@ -605,7 +557,7 @@
* @param superTypeBeingRemoved the super type name being removed (cannot be <code>null</code>)
* @return <code>true</code> if successfully removed
*/
- public boolean removeSuperType( String superTypeBeingRemoved ) {
+ public boolean removeSuperType( final String superTypeBeingRemoved ) {
if (this.superTypes.remove(superTypeBeingRemoved)) {
notifyChangeListeners(PropertyName.SUPERTYPES, superTypeBeingRemoved, null);
return true; // removed
@@ -620,8 +572,8 @@
* @see javax.jcr.nodetype.NodeTypeTemplate#setAbstract(boolean)
*/
@Override
- public void setAbstract( boolean newAbstract ) {
- AttributeState.Value newState = (newAbstract ? AttributeState.Value.IS : AttributeState.Value.IS_NOT);
+ public void setAbstract( final boolean newAbstract ) {
+ final AttributeState.Value newState = (newAbstract ? AttributeState.Value.IS : AttributeState.Value.IS_NOT);
changeState(PropertyName.ABSTRACT, newState);
}
@@ -631,12 +583,12 @@
* @see javax.jcr.nodetype.NodeTypeTemplate#setDeclaredSuperTypeNames(java.lang.String[])
*/
@Override
- public void setDeclaredSuperTypeNames( String[] newSuperTypes ) {
- List<String> oldValue = this.superTypes.getSupportedItems();
+ public void setDeclaredSuperTypeNames( final String[] newSuperTypes ) {
+ final List<String> oldValue = this.superTypes.getSupportedItems();
boolean changed = this.superTypes.clear();
if (!Utils.isEmpty(newSuperTypes)) {
- for (String superType : newSuperTypes) {
+ for (final String superType : newSuperTypes) {
if (this.superTypes.add(superType)) {
changed = true;
}
@@ -654,8 +606,8 @@
* @see javax.jcr.nodetype.NodeTypeTemplate#setMixin(boolean)
*/
@Override
- public void setMixin( boolean newMixin ) {
- AttributeState.Value newState = (newMixin ? AttributeState.Value.IS : AttributeState.Value.IS_NOT);
+ public void setMixin( final boolean newMixin ) {
+ final AttributeState.Value newState = (newMixin ? AttributeState.Value.IS : AttributeState.Value.IS_NOT);
changeState(PropertyName.MIXIN, newState);
}
@@ -665,8 +617,8 @@
* @see javax.jcr.nodetype.NodeTypeTemplate#setName(java.lang.String)
*/
@Override
- public void setName( String newName ) {
- Object oldValue = this.name.get();
+ public void setName( final String newName ) {
+ final Object oldValue = this.name.get();
if (this.name.set(newName)) {
notifyChangeListeners(PropertyName.NAME, oldValue, newName);
@@ -679,8 +631,8 @@
* @see javax.jcr.nodetype.NodeTypeTemplate#setOrderableChildNodes(boolean)
*/
@Override
- public void setOrderableChildNodes( boolean newOrderable ) {
- AttributeState.Value newState = (newOrderable ? AttributeState.Value.IS : AttributeState.Value.IS_NOT);
+ public void setOrderableChildNodes( final boolean newOrderable ) {
+ final AttributeState.Value newState = (newOrderable ? AttributeState.Value.IS : AttributeState.Value.IS_NOT);
changeState(PropertyName.ORDERABLE, newState);
}
@@ -690,8 +642,8 @@
* @see javax.jcr.nodetype.NodeTypeTemplate#setPrimaryItemName(java.lang.String)
*/
@Override
- public void setPrimaryItemName( String newPrimaryItem ) {
- String oldName = this.attributes.getPrimaryItem().getPrimaryItem();
+ public void setPrimaryItemName( final String newPrimaryItem ) {
+ final String oldName = this.attributes.getPrimaryItem().getPrimaryItem();
if (this.attributes.getPrimaryItem().setPrimaryItem(newPrimaryItem)) {
notifyChangeListeners(PropertyName.PRIMARY_ITEM, oldName, newPrimaryItem);
@@ -704,8 +656,8 @@
* @see javax.jcr.nodetype.NodeTypeTemplate#setQueryable(boolean)
*/
@Override
- public void setQueryable( boolean newQueryable ) {
- AttributeState.Value newState = (newQueryable ? AttributeState.Value.IS : AttributeState.Value.IS_NOT);
+ public void setQueryable( final boolean newQueryable ) {
+ final AttributeState.Value newState = (newQueryable ? AttributeState.Value.IS : AttributeState.Value.IS_NOT);
changeState(PropertyName.QUERYABLE, newState);
}
@@ -715,8 +667,8 @@
* @see org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- public String toCndNotation( NotationType notationType ) {
- StringBuilder builder = new StringBuilder("- "); //$NON-NLS-1$
+ public String toCndNotation( final NotationType notationType ) {
+ final StringBuilder builder = new StringBuilder("- "); //$NON-NLS-1$
{ // name
builder.append(NAME_NOTATION_PREFIX)
@@ -726,7 +678,7 @@
}
{ // super types
- String notation = this.superTypes.toCndNotation(notationType);
+ final String notation = this.superTypes.toCndNotation(notationType);
if (!Utils.isEmpty(notation)) {
builder.append(notation).append(getEndSuperTypesDelimiter());
@@ -734,7 +686,7 @@
}
{ // attributes
- String notation = this.attributes.toCndNotation(notationType);
+ final String notation = this.attributes.toCndNotation(notationType);
if (!Utils.isEmpty(notation)) {
builder.append(notation).append(getEndAttributesDelimiter());
@@ -745,7 +697,7 @@
if (!Utils.isEmpty(this.propertyDefinitions)) {
final String PD_DELIM = getPropertyDefinitionDelimiter();
- for (PropertyDefinition propDefn : this.propertyDefinitions) {
+ for (final PropertyDefinition propDefn : this.propertyDefinitions) {
builder.append(propDefn.toCndNotation(notationType)).append(PD_DELIM);
}
@@ -757,7 +709,7 @@
if (!Utils.isEmpty(this.childNodesDefinitions)) {
final String CND_DELIM = getChildNodeDefinitionDelimiter();
- for (ChildNodeDefinition childNodeDefn : this.childNodesDefinitions) {
+ for (final ChildNodeDefinition childNodeDefn : this.childNodesDefinitions) {
builder.append(childNodeDefn.toCndNotation(notationType)).append(CND_DELIM);
}
@@ -768,4 +720,55 @@
return builder.toString();
}
+ /**
+ * The property names whose <code>toString()</code> is used in {@link PropertyChangeEvent}s.
+ */
+ public enum PropertyName {
+
+ /**
+ * The abstract attribute.
+ */
+ ABSTRACT,
+
+ /**
+ * The collection for child node definitions.
+ */
+ CHILD_NODES,
+
+ /**
+ * The mixin attribute.
+ */
+ MIXIN,
+
+ /**
+ * The node type name.
+ */
+ NAME,
+
+ /**
+ * The orderable attribute.
+ */
+ ORDERABLE,
+
+ /**
+ * The primary item attribute.
+ */
+ PRIMARY_ITEM,
+
+ /**
+ * The collection of property definitions.
+ */
+ PROPERTY_DEFINITIONS,
+
+ /**
+ * The queryable attribute.
+ */
+ QUERYABLE,
+
+ /**
+ * The collection for super types.
+ */
+ SUPERTYPES
+ }
+
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Abstract.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Abstract.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Abstract.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -9,8 +9,14 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+/**
+ * The abstract attribute used by node type definitions.
+ */
public class Abstract extends AttributeState {
+ /**
+ * The CND notation for each notation type.
+ */
public static final String[] NOTATION = new String[] { "abstract", "abs", "a" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/AttributeState.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/AttributeState.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/AttributeState.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -11,16 +11,50 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
/**
- *
+ * An attribute will have either a supported, unsupported, or variant state.
*/
public abstract class AttributeState implements CndElement {
+ /**
+ * The attribute state possible values.
+ */
+ public enum Value {
+
+ /**
+ * Indicates the attribute is supported.
+ */
+ IS,
+
+ /**
+ * Indicates the attribute is not supported.
+ */
+ IS_NOT,
+
+ /**
+ * Indicates the attribute is a variant.
+ */
+ VARIANT
+ }
+
+ /**
+ * The character used in CND notation to indicate the attribute is a variant.
+ */
public static final char VARIANT_CHAR = '?';
+ /**
+ * The CND variant character as a string.
+ *
+ * @see #VARIANT_CHAR
+ */
public static final String VARIANT_STRING = Character.toString(VARIANT_CHAR);
private Value state;
+ /**
+ * Constructs a not supported attribute state.
+ *
+ * @see Value#IS_NOT
+ */
public AttributeState() {
this.state = Value.IS_NOT;
}
@@ -31,25 +65,40 @@
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals( Object obj ) {
+ public boolean equals( final Object obj ) {
if ((obj == null) || !getClass().equals(obj.getClass())) {
return false;
}
- AttributeState that = (AttributeState)obj;
+ final AttributeState that = (AttributeState)obj;
return (this.state == that.state);
}
+ /**
+ * @return the attribute state (never <code>null</code>)
+ */
public Value get() {
return this.state;
}
+ /**
+ * @return the attribute's compact CND notation (can be <code>null</code> or empty)
+ */
protected abstract String getCompactCndNotation();
+ /**
+ * @return the attribute's compressed CND notation (can be <code>null</code> or empty)
+ */
protected abstract String getCompressedCndNotation();
+ /**
+ * @return the attribute's long CND notation (can be <code>null</code> or empty)
+ */
protected abstract String getLongCndNotation();
+ /**
+ * @return <code>true</code> if the CND notation is not empty
+ */
protected boolean hasCndNotation() {
return !isNot();
}
@@ -64,19 +113,34 @@
return super.hashCode();
}
+ /**
+ * @return <code>true</code> if attribute state is {@link Value#IS}.
+ */
public boolean is() {
return (this.state == Value.IS);
}
+ /**
+ * @return <code>true</code> if attribute state is {@link Value#IS_NOT}.
+ */
public boolean isNot() {
return (this.state == Value.IS_NOT);
}
+ /**
+ * @return <code>true</code> if attribute state is {@link Value#VARIANT}.
+ */
public boolean isVariant() {
return (this.state == Value.VARIANT);
}
- public boolean set( Value newState ) {
+ /**
+ * @param newState the proposed new state (cannot be <code>null</code>)
+ * @return <code>true</code> if state was changed
+ */
+ public boolean set( final Value newState ) {
+ Utils.isNotNull(newState, "newState"); //$NON-NLS-1$
+
if (this.state != newState) {
this.state = newState;
return true;
@@ -91,7 +155,7 @@
* @see org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- public String toCndNotation( NotationType notationType ) {
+ public String toCndNotation( final NotationType notationType ) {
if (hasCndNotation()) {
String notation = Utils.EMPTY_STRING;
@@ -113,17 +177,15 @@
return Utils.EMPTY_STRING;
}
- protected String toVariantCndNotation( String cndNotation ) {
+ /**
+ * @param cndNotation the CND notation without the variant indicator (can be <code>null</code> or empty)
+ * @return the variant CND notation (never <code>null</code> or empty)
+ */
+ protected String toVariantCndNotation( final String cndNotation ) {
if (Utils.isEmpty(cndNotation)) {
return String.valueOf(AttributeState.VARIANT_CHAR);
}
return cndNotation + AttributeState.VARIANT_CHAR;
}
-
- public enum Value {
- IS,
- IS_NOT,
- VARIANT
- }
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Autocreated.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Autocreated.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Autocreated.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -9,8 +9,15 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+/**
+ * The autocreated attribute used by property definitions and child node definitions. When set, the property is automatically
+ * created when the parent node is created. It mandates that a default value is set.
+ */
public class Autocreated extends AttributeState {
+ /**
+ * The CND notation for each notation type.
+ */
public static final String[] NOTATION = new String[] { "autocreated", "aut", "a" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultType.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultType.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultType.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -10,8 +10,14 @@
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.cnd.LocalName;
+/**
+ * The child node definitions default type property.
+ */
public class DefaultType extends AttributeState {
+ /**
+ * The CND notation for each notation type.
+ */
public static final String NOTATION = "="; //$NON-NLS-1$
private final LocalName defaultType = new LocalName();
@@ -23,7 +29,7 @@
*/
@Override
public Value get() {
- Value state = super.get();
+ final Value state = super.get();
if (state == Value.VARIANT) {
return Value.VARIANT;
@@ -43,7 +49,7 @@
*/
@Override
protected String getCompactCndNotation() {
- return NOTATION;
+ return getLongCndNotation();
}
/**
@@ -53,9 +59,12 @@
*/
@Override
protected String getCompressedCndNotation() {
- return NOTATION;
+ return getLongCndNotation();
}
+ /**
+ * @return the default type (can be <code>null</code> or empty)
+ */
public String getDefaultType() {
return this.defaultType.get();
}
@@ -67,16 +76,23 @@
*/
@Override
protected String getLongCndNotation() {
- return NOTATION;
+ String defaultType = getDefaultType();
+
+ if (Utils.isEmpty(defaultType)) {
+ return NOTATION;
+ }
+
+ return NOTATION + defaultType;
}
/**
- * {@inheritDoc}
+ * {@inheritDoc} <strong>Can only be used to change to a variant state. Use {@link DefaultType#setDefaultType(String)} to set to
+ * other states</strong>
*
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#set(org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState.Value)
*/
@Override
- public boolean set( Value newState ) {
+ public boolean set( final Value newState ) {
if (newState == Value.VARIANT) {
if (super.set(Value.VARIANT)) {
return true;
@@ -86,7 +102,11 @@
return false;
}
- public boolean setDefaultType( String newDefaultType ) {
+ /**
+ * @param newDefaultType the proposed new value for the default type (can be <code>null</code> or empty)
+ * @return <code>true</code> if changed
+ */
+ public boolean setDefaultType( final String newDefaultType ) {
if (this.defaultType.set(newDefaultType)) {
if (Utils.isEmpty(newDefaultType) && !isVariant()) {
super.set(Value.IS_NOT);
@@ -103,26 +123,10 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- public String toCndNotation( NotationType notationType ) {
- String notation = super.toCndNotation(notationType);
-
- if (!isVariant() && is()) {
- notation += ' ' + this.defaultType.toCndNotation(notationType);
- }
-
- return notation;
- }
-
- /**
- * {@inheritDoc}
- *
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#toVariantCndNotation(java.lang.String)
*/
@Override
- protected String toVariantCndNotation( String cndNotation ) {
- return cndNotation + ' ' + AttributeState.VARIANT_CHAR;
+ protected String toVariantCndNotation( final String cndNotation ) {
+ return cndNotation + AttributeState.VARIANT_CHAR;
}
}
\ No newline at end of file
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultValues.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultValues.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultValues.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -16,19 +16,25 @@
*/
public final class DefaultValues extends ListAttributeState<String> {
+ /**
+ * The CND list prefix.
+ */
public static final String NOTATION_PREFIX = "="; //$NON-NLS-1$
+ /**
+ * @return the JCR value for each default value (never <code>null</code>)
+ */
public javax.jcr.Value[] asJcrValues() {
- Collection<String> defaultValues = getSupportedItems();
+ final Collection<String> defaultValues = getSupportedItems();
if (Utils.isEmpty(defaultValues)) {
return new javax.jcr.Value[0];
}
- javax.jcr.Value[] jcrValues = new javax.jcr.Value[defaultValues.size()];
+ final javax.jcr.Value[] jcrValues = new javax.jcr.Value[defaultValues.size()];
int i = 0;
- for (String defaultValue : defaultValues) {
+ for (final String defaultValue : defaultValues) {
jcrValues[i++] = new PropertyValue(PropertyType.STRING.asJcrValue(), defaultValue);
}
@@ -41,7 +47,7 @@
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getCndNotationPrefix(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- protected String getCndNotationPrefix( NotationType notationType ) {
+ protected String getCndNotationPrefix( final NotationType notationType ) {
return NOTATION_PREFIX;
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ListAttributeState.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ListAttributeState.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ListAttributeState.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -18,7 +18,7 @@
import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
/**
- *
+ * @param <E> the class of the list items
*/
public abstract class ListAttributeState<E extends Comparable> extends AttributeState {
@@ -31,7 +31,7 @@
* @param item the item being added (cannot be <code>null</code>)
* @return <code>true</code> if successfully added
*/
- public boolean add( E item ) {
+ public boolean add( final E item ) {
Utils.isNotNull(item, "item"); //$NON-NLS-1$
if (this.supported == null) {
@@ -75,7 +75,7 @@
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals( Object obj ) {
+ public boolean equals( final Object obj ) {
if ((obj == null) || !getClass().equals(obj.getClass())) {
return false;
}
@@ -84,9 +84,9 @@
return true;
}
- ListAttributeState that = (ListAttributeState)obj;
- List<E> thatSupportedItems = that.getSupportedItems();
- List<E> thisSupportedItems = getSupportedItems();
+ final ListAttributeState that = (ListAttributeState)obj;
+ final List<E> thatSupportedItems = that.getSupportedItems();
+ final List<E> thisSupportedItems = getSupportedItems();
if (Utils.isEmpty(thisSupportedItems)) {
return Utils.isEmpty(thatSupportedItems);
@@ -103,9 +103,17 @@
return thisSupportedItems.containsAll(thatSupportedItems);
}
+ /**
+ * @param notationType the notation type whose CND notation prefix is being requested (cannot be <code>null</code>)
+ * @return the CND notation prefix (can be <code>null</code> or empty)
+ */
protected abstract String getCndNotationPrefix( NotationType notationType );
- protected String getCndNotationSuffix( NotationType notationType ) {
+ /**
+ * @param notationType the notation type whose CND notation suffix is being requested (cannot be <code>null</code>)
+ * @return the CND notation suffix (can be <code>null</code> or empty)
+ */
+ protected String getCndNotationSuffix( final NotationType notationType ) {
return Utils.EMPTY_STRING;
}
@@ -129,7 +137,10 @@
throw new UnsupportedOperationException();
}
- protected String getDelimiter() {
+ /**
+ * @return the delimiter used after the list prefix (never <code>null</code> but can be empty)
+ */
+ protected String getListPrefixEndDelimiter() {
return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER);
}
@@ -178,14 +189,14 @@
* @param item the item being removed (cannot be <code>null</code>)
* @return <code>true</code> if successfully removed
*/
- public boolean remove( E item ) {
+ public boolean remove( final E item ) {
Utils.isNotNull(item, "item"); //$NON-NLS-1$
if (this.supported == null) {
return false;
}
- boolean removed = this.supported.remove(item);
+ final boolean removed = this.supported.remove(item);
if (this.supported.isEmpty()) {
this.supported = null;
@@ -204,7 +215,7 @@
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#set(org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState.Value)
*/
@Override
- public final boolean set( Value newState ) {
+ public final boolean set( final Value newState ) {
if (Value.VARIANT == newState) {
clear();
return super.set(Value.VARIANT);
@@ -213,8 +224,12 @@
return false; // other states set by adding and removing supported items
}
- protected String supportedItemsCndNotation( NotationType notationType ) {
- List<E> items = new ArrayList<E>(getSupportedItems());
+ /**
+ * @param notationType the CND notation type to use (cannot be <code>null</code>)
+ * @return the CND notation (never <code>null</code> but can be empty)
+ */
+ protected String supportedItemsCndNotation( final NotationType notationType ) {
+ final List<E> items = new ArrayList<E>(getSupportedItems());
Collections.sort(items);
if (items.isEmpty()) {
@@ -222,7 +237,7 @@
}
if (items.size() == 1) {
- E firstItem = items.iterator().next();
+ final E firstItem = items.iterator().next();
if (firstItem instanceof CndElement) {
return ((CndElement)firstItem).toCndNotation(notationType);
@@ -231,10 +246,10 @@
return firstItem.toString();
}
- StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
- for (Iterator<E> itr = items.iterator(); itr.hasNext();) {
- E item = itr.next();
+ for (final Iterator<E> itr = items.iterator(); itr.hasNext();) {
+ final E item = itr.next();
if (item instanceof CndElement) {
builder.append(((CndElement)item).toCndNotation(notationType));
@@ -243,7 +258,7 @@
}
if (itr.hasNext()) {
- builder.append(CndElement.LIST_DELIMITER);
+ builder.append(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER);
}
}
@@ -252,9 +267,9 @@
/**
* @param item the item being checked (cannot be <code>null</code>)
- * @return
+ * @return <code>true</code> if item is contained in list
*/
- public boolean supports( E item ) {
+ public boolean supports( final E item ) {
Utils.isNotNull(item, "item"); //$NON-NLS-1$
return this.supported.contains(item);
}
@@ -265,15 +280,15 @@
* @see org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- public String toCndNotation( NotationType notationType ) {
+ public String toCndNotation( final NotationType notationType ) {
if (hasCndNotation()) {
- StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
if (!Utils.isEmpty(getCndNotationPrefix(notationType))) {
builder.append(getCndNotationPrefix(notationType));
}
- String delim = getDelimiter();
+ final String delim = getListPrefixEndDelimiter();
if (!Utils.isEmpty(delim)) {
builder.append(delim);
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mandatory.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mandatory.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mandatory.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -9,8 +9,15 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+/**
+ * The mandatory attribute used by property definitions and child node definitions. When set, the property is mandatory, meaning it
+ * must be present in order to save the node.
+ */
public class Mandatory extends AttributeState {
+ /**
+ * The CND notation for each notation type.
+ */
public static final String[] NOTATION = new String[] { "mandatory", "man", "m" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mixin.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mixin.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mixin.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -9,8 +9,14 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+/**
+ * The mixin attribute used by node type definitions.
+ */
public class Mixin extends AttributeState {
+ /**
+ * The CND notation for each notation type.
+ */
public static final String[] NOTATION = new String[] { "mixin", "mix", "m" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Multiple.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Multiple.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Multiple.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -9,8 +9,14 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+/**
+ * The multiple attribute used by property definitions. When set, the property is multi-valued, accepting a list of values.
+ */
public class Multiple extends AttributeState {
+ /**
+ * The CND notation for each notation type.
+ */
public static final String[] NOTATION = new String[] { "multiple", "mul", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoFullText.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoFullText.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoFullText.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -9,8 +9,14 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+/**
+ * The no full text search attribute used by the property definitions.
+ */
public class NoFullText extends AttributeState {
+ /**
+ * The CND notation for each notation type.
+ */
public static final String[] NOTATION = new String[] { "nofulltext", "nof", "nof" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoQueryOrder.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoQueryOrder.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoQueryOrder.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -9,8 +9,14 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+/**
+ * The no query order attribute used by property definitions.
+ */
public class NoQueryOrder extends AttributeState {
+ /**
+ * The CND notation for each notation type.
+ */
public static final String[] NOTATION = new String[] { "noqueryorder", "nqord", "nqord" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeAttributes.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeAttributes.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeAttributes.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -14,22 +14,23 @@
import org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState.Value;
/**
- *
+ * The child node definition attribute collection.
*/
public class NodeAttributes implements CndElement {
- public static final char DEFAULT_FORMAT_DELIMITER = ' ';
+ private final Autocreated autocreated;
- private Autocreated autocreated;
+ private final Mandatory mandatory;
- private Mandatory mandatory;
+ private final Protected notDeletable;
- private Protected notDeletable;
-
private OnParentVersion opv;
- private SameNameSiblings sns;
+ private final SameNameSiblings sns;
+ /**
+ * Constructs node attributes all set to default values.
+ */
public NodeAttributes() {
this.autocreated = new Autocreated();
this.mandatory = new Mandatory();
@@ -44,7 +45,7 @@
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals( Object obj ) {
+ public boolean equals( final Object obj ) {
if ((obj == null) || !getClass().equals(obj.getClass())) {
return false;
}
@@ -53,12 +54,15 @@
return true;
}
- NodeAttributes that = (NodeAttributes)obj;
+ final NodeAttributes that = (NodeAttributes)obj;
return (this.autocreated.equals(that.autocreated) && this.mandatory.equals(that.mandatory)
&& this.notDeletable.equals(that.notDeletable) && (this.opv == that.opv) && this.sns.equals(that.sns));
}
+ /**
+ * @return the autocreated attribute (never <code>null</code>)
+ */
public Autocreated getAutocreated() {
return this.autocreated;
}
@@ -67,18 +71,30 @@
return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.CHILD_NODE_ATTRIBUTES_DELIMITER);
}
+ /**
+ * @return the mandatory attribute (never <code>null</code>)
+ */
public Mandatory getMandatory() {
return this.mandatory;
}
+ /**
+ * @return the on parent version attribute (never <code>null</code>)
+ */
public OnParentVersion getOnParentVersion() {
return this.opv;
}
+ /**
+ * @return the protected attribute (never <code>null</code>)
+ */
public Protected getProtected() {
return this.notDeletable;
}
+ /**
+ * @return the same named siblings attribute (never <code>null</code>)
+ */
public SameNameSiblings getSameNameSiblings() {
return this.sns;
}
@@ -93,15 +109,29 @@
return Utils.hashCode(this.autocreated, this.mandatory, this.notDeletable, this.opv, this.sns);
}
- public boolean setAutocreated( Value newState ) {
+ /**
+ * @param newState the new value to set the autocreated attribute state to (cannot be <code>null</code>)
+ * @return <code>true</code> if the state changed
+ */
+ public boolean setAutocreated( final Value newState ) {
return this.autocreated.set(newState);
}
- public boolean setMandatory( Value newState ) {
+ /**
+ * @param newState the new value to set the mandatory attribute state to (cannot be <code>null</code>)
+ * @return <code>true</code> if state changed
+ */
+ public boolean setMandatory( final Value newState ) {
return this.mandatory.set(newState);
}
- public boolean setOnParentVersion( OnParentVersion newOpv ) {
+ /**
+ * @param newOpv the new value to set the on parent version attribute to (cannot be <code>null</code>)
+ * @return <code>true</code> if changed
+ */
+ public boolean setOnParentVersion( final OnParentVersion newOpv ) {
+ Utils.isNotNull(newOpv, "newOpv"); //$NON-NLS-1$
+
if (this.opv != newOpv) {
this.opv = newOpv;
return true;
@@ -110,11 +140,19 @@
return false;
}
- public boolean setProtected( Value newState ) {
+ /**
+ * @param newState the new value to set the protected attribute state to (cannot be <code>null</code>)
+ * @return <code>true</code> if state changed
+ */
+ public boolean setProtected( final Value newState ) {
return this.notDeletable.set(newState);
}
- public boolean setSameNameSibling( Value newState ) {
+ /**
+ * @param newState the new value to set the same named siblings attribute state to (cannot be <code>null</code>)
+ * @return <code>true</code> if state changed
+ */
+ public boolean setSameNameSibling( final Value newState ) {
return this.sns.set(newState);
}
@@ -124,9 +162,9 @@
* @see org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- public String toCndNotation( NotationType notationType ) {
- String delim = getFormatDelimiter();
- StringBuilder builder = new StringBuilder();
+ public String toCndNotation( final NotationType notationType ) {
+ final String delim = getFormatDelimiter();
+ final StringBuilder builder = new StringBuilder();
boolean addDelim = false;
{ // autocreated
@@ -134,7 +172,7 @@
builder.append(delim);
}
- String notation = this.autocreated.toCndNotation(notationType);
+ final String notation = this.autocreated.toCndNotation(notationType);
if (!Utils.isEmpty(notation)) {
builder.append(notation);
@@ -147,7 +185,7 @@
builder.append(delim);
}
- String notation = this.mandatory.toCndNotation(notationType);
+ final String notation = this.mandatory.toCndNotation(notationType);
if (!Utils.isEmpty(notation)) {
builder.append(notation);
@@ -160,7 +198,7 @@
builder.append(delim);
}
- String notation = this.notDeletable.toCndNotation(notationType);
+ final String notation = this.notDeletable.toCndNotation(notationType);
if (!Utils.isEmpty(notation)) {
builder.append(notation);
@@ -173,7 +211,7 @@
builder.append(delim);
}
- String notation = this.opv.toCndNotation(notationType);
+ final String notation = this.opv.toCndNotation(notationType);
if (!Utils.isEmpty(notation)) {
builder.append(notation);
@@ -186,7 +224,7 @@
builder.append(delim);
}
- String notation = this.sns.toCndNotation(notationType);
+ final String notation = this.sns.toCndNotation(notationType);
if (!Utils.isEmpty(notation)) {
builder.append(notation);
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeTypeAttributes.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeTypeAttributes.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeTypeAttributes.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -13,7 +13,7 @@
import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
/**
- *
+ * Property attributes of a node type definitions.
*/
public class NodeTypeAttributes implements CndElement {
@@ -27,6 +27,9 @@
private Queryable queryable;
+ /**
+ * Constructs a node type definition's attribute collection all set to there default values.
+ */
public NodeTypeAttributes() {
this.orderable = new Orderable();
this.mixin = new Mixin();
@@ -42,11 +45,11 @@
* @param initialQueryable the initial queryable value (can be <code>null</code>)
* @param initialPrimaryItem the initial primary item value (can be <code>null</code>)
*/
- public NodeTypeAttributes( Orderable initialOrderable,
- Mixin initialMixin,
- Abstract initialAbstract,
- Queryable initialQueryable,
- PrimaryItem initialPrimaryItem ) {
+ public NodeTypeAttributes( final Orderable initialOrderable,
+ final Mixin initialMixin,
+ final Abstract initialAbstract,
+ final Queryable initialQueryable,
+ final PrimaryItem initialPrimaryItem ) {
this();
if (!this.orderable.equals(initialOrderable)) {
@@ -76,7 +79,7 @@
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals( Object obj ) {
+ public boolean equals( final Object obj ) {
if ((obj == null) || !getClass().equals(obj.getClass())) {
return false;
}
@@ -85,12 +88,15 @@
return true;
}
- NodeTypeAttributes that = (NodeTypeAttributes)obj;
+ final NodeTypeAttributes that = (NodeTypeAttributes)obj;
return (this.mixin.equals(that.mixin) && this.notConcrete.equals(that.notConcrete) && this.orderable.equals(that.orderable)
&& this.queryable.equals(that.queryable) && this.primaryItem.equals(that.primaryItem));
}
+ /**
+ * @return the abstract attribute (never <code>null</code>)
+ */
public Abstract getAbstract() {
return this.notConcrete;
}
@@ -99,18 +105,30 @@
return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER);
}
+ /**
+ * @return the mixin attribute (never <code>null</code>)
+ */
public Mixin getMixin() {
return this.mixin;
}
+ /**
+ * @return the orderable attribute (never <code>null</code>)
+ */
public Orderable getOrderable() {
return this.orderable;
}
+ /**
+ * @return the primary item attribute (never <code>null</code>)
+ */
public PrimaryItem getPrimaryItem() {
return this.primaryItem;
}
+ /**
+ * @return the queryable attribute (never <code>null</code>)
+ */
public Queryable getQueryable() {
return this.queryable;
}
@@ -125,31 +143,53 @@
return Utils.hashCode(this.mixin, this.notConcrete, this.orderable, this.queryable, this.primaryItem);
}
- public boolean isPrimaryItemVariant() {
- return this.primaryItem.isVariant();
- }
-
- public boolean setAbstract( AttributeState.Value newState ) {
+ /**
+ * @param newState the proposed new state of the abstract attribute (cannot be <code>null</code>)
+ * @return <code>true</code> if the state was changed
+ */
+ public boolean setAbstract( final AttributeState.Value newState ) {
return this.notConcrete.set(newState);
}
- public boolean setMixin( AttributeState.Value newState ) {
+ /**
+ * @param newState the proposed new state of the mixin attribute (cannot be <code>null</code>)
+ * @return <code>true</code> if the state was changed
+ */
+ public boolean setMixin( final AttributeState.Value newState ) {
return this.mixin.set(newState);
}
- public boolean setOrderable( AttributeState.Value newState ) {
+ /**
+ * @param newState the proposed new state of the orderable attribute (cannot be <code>null</code>)
+ * @return <code>true</code> if the state was changed
+ */
+ public boolean setOrderable( final AttributeState.Value newState ) {
return this.orderable.set(newState);
}
- public boolean setPrimaryItem( AttributeState.Value newState ) {
+ /**
+ * <strong>Can only be used to set to variant state.</strong>
+ *
+ * @param newState the proposed new state of the primary item attribute (cannot be <code>null</code>)
+ * @return <code>true</code> if the state was changed
+ */
+ public boolean setPrimaryItem( final AttributeState.Value newState ) {
return this.primaryItem.set(newState);
}
- public boolean setPrimaryItem( String newPrimaryItem ) {
+ /**
+ * @param newPrimaryItem the proposed new value for the primary item (can be <code>null</code> or empty)
+ * @return <code>true</code> if primary item was changed
+ */
+ public boolean setPrimaryItem( final String newPrimaryItem ) {
return this.primaryItem.setPrimaryItem(newPrimaryItem);
}
- public boolean setQueryable( AttributeState.Value newState ) {
+ /**
+ * @param newState the proposed new state of the queryable attribute (cannot be <code>null</code>)
+ * @return <code>true</code> if the state was changed
+ */
+ public boolean setQueryable( final AttributeState.Value newState ) {
return this.queryable.set(newState);
}
@@ -159,9 +199,9 @@
* @see org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- public String toCndNotation( NotationType notationType ) {
+ public String toCndNotation( final NotationType notationType ) {
final String DELIM = getFormatDelimiter();
- StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
boolean addDelim = Utils.build(builder, false, DELIM, this.orderable.toCndNotation(notationType));
addDelim = Utils.build(builder, addDelim, DELIM, this.mixin.toCndNotation(notationType));
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/OnParentVersion.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/OnParentVersion.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/OnParentVersion.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -14,46 +14,94 @@
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+/**
+ * The primary item attribute used by child node definitions and property definitions.
+ */
public enum OnParentVersion implements CndElement {
+ /**
+ * Upon check-in, a VersionException will be thrown as the creation of a version is prohibited.
+ */
ABORT(OnParentVersionAction.ABORT),
+
+ /**
+ * Upon check-in, the new version will contain this property. However, when the node is restored from a previous node, the value
+ * of this property is NOT being restored.
+ */
COMPUTE(OnParentVersionAction.COMPUTE),
+
+ /**
+ * Upon check-in, the value of the property will be copied to the new version.
+ */
COPY(OnParentVersionAction.COPY),
+
+ /**
+ * Upon check-in, the version entry will not contain this property, i.e. it is not versioned.
+ */
IGNORE(OnParentVersionAction.IGNORE),
+
+ /**
+ * Upon check-in, a new property with the same name will be created and re-initialized with any default values specified or as
+ * empty. Essentially, the property is re-set when a new version of the node is created.
+ */
INITIALIZE(OnParentVersionAction.INITIALIZE),
+
+ /**
+ * Indicates that OPV is a variant. Cannot be used with {@link #find(String)}.
+ */
VARIANT(-1),
+
+ /**
+ * Upon check-in, the value of the property will be copied to the new version.
+ */
VERSION(OnParentVersionAction.VERSION);
+ /**
+ * The default value. Value is {@value} .
+ */
public static OnParentVersion DEFAULT_VALUE = COPY;
- public static OnParentVersion findUsingJcrValue( int jcrValue ) {
- for (OnParentVersion opv : OnParentVersion.values()) {
- if (opv.asJcrValue() == jcrValue) {
+ /**
+ * @param notation the CND representation of the OPV (cannot be <code>null</code> or empty)
+ * @return the OPV (never <code>null</code>)
+ * @throws IllegalArgumentException if the <code>jcrValue</code> is not valid
+ */
+ public static OnParentVersion find( final String notation ) {
+ for (final OnParentVersion opv : OnParentVersion.values()) {
+ if (opv.toCndNotation(NotationType.LONG).equalsIgnoreCase(notation)
+ || opv.toCndNotation(NotationType.COMPRESSED).equalsIgnoreCase(notation)
+ || opv.toCndNotation(NotationType.COMPACT).equalsIgnoreCase(notation)) {
return opv;
}
}
- throw new IllegalArgumentException(NLS.bind(Messages.invalidFindUsingJcrValueRequest, jcrValue));
+ throw new IllegalArgumentException(NLS.bind(Messages.invalidFindRequest, notation));
}
- public static OnParentVersion find( String notation ) {
- for (OnParentVersion opv : OnParentVersion.values()) {
- if (opv.toCndNotation(NotationType.LONG).equalsIgnoreCase(notation)
- || opv.toCndNotation(NotationType.COMPRESSED).equalsIgnoreCase(notation)
- || opv.toCndNotation(NotationType.COMPACT).equalsIgnoreCase(notation)) {
+ /**
+ * @param jcrValue the integer representation
+ * @return the OPV (never <code>null</code>)
+ * @throws IllegalArgumentException if the <code>jcrValue</code> is not valid
+ */
+ public static OnParentVersion findUsingJcrValue( final int jcrValue ) {
+ for (final OnParentVersion opv : OnParentVersion.values()) {
+ if (opv.asJcrValue() == jcrValue) {
return opv;
}
}
- throw new IllegalArgumentException(NLS.bind(Messages.invalidFindRequest, notation));
+ throw new IllegalArgumentException(NLS.bind(Messages.invalidFindUsingJcrValueRequest, jcrValue));
}
+ /**
+ * @return a collection of all valid CND notation values (never <code>null</code> or empty)
+ */
public static String[] toArray() {
- OnParentVersion[] allOpv = OnParentVersion.values();
- String[] notations = new String[allOpv.length];
+ final OnParentVersion[] allOpv = OnParentVersion.values();
+ final String[] notations = new String[allOpv.length];
int i = 0;
- for (OnParentVersion opv : allOpv) {
+ for (final OnParentVersion opv : allOpv) {
notations[i++] = opv.toCndNotation(NotationType.LONG);
}
@@ -62,10 +110,13 @@
private final int jcrValue;
- private OnParentVersion( int jcrValue ) {
+ private OnParentVersion( final int jcrValue ) {
this.jcrValue = jcrValue;
}
+ /**
+ * @return the JCR integer representation
+ */
public int asJcrValue() {
return this.jcrValue;
}
@@ -76,7 +127,7 @@
* @see org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- public String toCndNotation( NotationType notationType ) {
+ public String toCndNotation( final NotationType notationType ) {
if ((this == DEFAULT_VALUE) && (NotationType.LONG != notationType)) {
return Utils.EMPTY_STRING;
}
@@ -87,14 +138,14 @@
return super.toString();
}
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Enum#toString()
- */
- @Override
- public String toString() {
- return OnParentVersionAction.nameFromValue(asJcrValue());
- }
+ //
+ // /**
+ // * {@inheritDoc}
+ // *
+ // * @see java.lang.Enum#toString()
+ // */
+ // @Override
+ // public String toString() {
+ // return OnParentVersionAction.nameFromValue(asJcrValue());
+ // }
}
\ No newline at end of file
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Orderable.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Orderable.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Orderable.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -9,8 +9,14 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+/**
+ * The orderable attribute used by node type definitions.
+ */
public class Orderable extends AttributeState {
+ /**
+ * The CND notation for each notation type.
+ */
public static final String[] NOTATION = new String[] { "orderable", "ord", "o" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItem.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItem.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItem.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -11,20 +11,26 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
import org.jboss.tools.modeshape.jcr.cnd.LocalName;
+/**
+ * The primary item attribute used by node type definitions. This primary item may be a child node or a property.
+ */
public class PrimaryItem extends AttributeState {
+ /**
+ * The CND notation for each notation type.
+ */
public static final String[] NOTATION = new String[] { "primaryitem", "!", "!" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
private final LocalName primaryItem = new LocalName();
/**
* {@inheritDoc}
- *
+ *
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#get()
*/
@Override
public Value get() {
- Value state = super.get();
+ final Value state = super.get();
if (state == Value.VARIANT) {
return Value.VARIANT;
@@ -67,18 +73,20 @@
return NOTATION[CndElement.NotationType.LONG_INDEX];
}
+ /**
+ * @return the primary item (can be <code>null</code> or empty)
+ */
public String getPrimaryItem() {
return this.primaryItem.get();
}
/**
- * {@inheritDoc}
- * Only can be used to set to variant state.
- *
+ * {@inheritDoc} Only can be used to set to variant state.
+ *
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#set(org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState.Value)
*/
@Override
- public boolean set( Value newState ) {
+ public boolean set( final Value newState ) {
if (newState == Value.VARIANT) {
if (super.set(Value.VARIANT)) {
return true;
@@ -88,7 +96,11 @@
return false;
}
- public boolean setPrimaryItem( String newPrimaryItem ) {
+ /**
+ * @param newPrimaryItem the proposed new primary item (can be <code>null</code> or empty)
+ * @return <code>true</code> if the primary item was changed
+ */
+ public boolean setPrimaryItem( final String newPrimaryItem ) {
if (this.primaryItem.set(newPrimaryItem)) {
if (Utils.isEmpty(newPrimaryItem) && !isVariant()) {
super.set(Value.IS_NOT);
@@ -108,7 +120,7 @@
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- public String toCndNotation( NotationType notationType ) {
+ public String toCndNotation( final NotationType notationType ) {
String notation = super.toCndNotation(notationType);
if (!isVariant() && is()) {
@@ -117,14 +129,14 @@
return notation;
}
-
+
/**
* {@inheritDoc}
- *
+ *
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#toVariantCndNotation(java.lang.String)
*/
@Override
- protected String toVariantCndNotation( String cndNotation ) {
+ protected String toVariantCndNotation( final String cndNotation ) {
return cndNotation + ' ' + AttributeState.VARIANT_CHAR;
}
}
\ No newline at end of file
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyAttributes.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyAttributes.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyAttributes.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -13,7 +13,7 @@
import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
/**
- *
+ * Property attributes of a property definitions.
*/
public class PropertyAttributes implements CndElement {
@@ -33,6 +33,9 @@
private QueryOperators queryOps;
+ /**
+ * Constructs a property definition's attribute collecdtion all set to there default values.
+ */
public PropertyAttributes() {
this.autocreated = new Autocreated();
this.mandatory = new Mandatory();
@@ -120,6 +123,9 @@
&& (this.opv == that.opv) && this.queryOps.equals(that.queryOps));
}
+ /**
+ * @return the autocreated attribute (never <code>null</code>)
+ */
public Autocreated getAutocreated() {
return this.autocreated;
}
@@ -128,30 +134,51 @@
return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER);
}
+ /**
+ * @return the mandatory attribute (never <code>null</code>)
+ */
public Mandatory getMandatory() {
return this.mandatory;
}
+ /**
+ * @return the multiple attribute (never <code>null</code>)
+ */
public Multiple getMultiple() {
return this.multiple;
}
+ /**
+ * @return the no full text search attribute (never <code>null</code>)
+ */
public NoFullText getNoFullText() {
return this.noFullText;
}
+ /**
+ * @return the no query order attribute (never <code>null</code>)
+ */
public NoQueryOrder getNoQueryOrder() {
return this.noQueryOrder;
}
+ /**
+ * @return the on parent version attribute (never <code>null</code>)
+ */
public OnParentVersion getOnParentVersion() {
return this.opv;
}
+ /**
+ * @return the protected attribute (never <code>null</code>)
+ */
public Protected getProtected() {
return this.notDeletable;
}
+ /**
+ * @return the query operators attribute (never <code>null</code>)
+ */
public QueryOperators getQueryOps() {
return this.queryOps;
}
@@ -167,26 +194,50 @@
this.notDeletable, this.opv, this.queryOps);
}
+ /**
+ * @param newState the proposed new state of the autocreated attribute (cannot be <code>null</code>)
+ * @return <code>true</code> if the state was changed
+ */
public boolean setAutocreated( AttributeState.Value newState ) {
return this.autocreated.set(newState);
}
+ /**
+ * @param newState the proposed new state of the mandatory attribute (cannot be <code>null</code>)
+ * @return <code>true</code> if the state was changed
+ */
public boolean setMandatory( AttributeState.Value newState ) {
return this.mandatory.set(newState);
}
+ /**
+ * @param newState the proposed new state of the multiple attribute (cannot be <code>null</code>)
+ * @return <code>true</code> if the state was changed
+ */
public boolean setMultiple( AttributeState.Value newState ) {
return this.multiple.set(newState);
}
+ /**
+ * @param newState the proposed new state of the no full text search attribute (cannot be <code>null</code>)
+ * @return <code>true</code> if the state was changed
+ */
public boolean setNoFullText( AttributeState.Value newState ) {
return this.noFullText.set(newState);
}
+ /**
+ * @param newState the proposed new state of the no query order attribute (cannot be <code>null</code>)
+ * @return <code>true</code> if the state was changed
+ */
public boolean setNoQueryOrder( AttributeState.Value newState ) {
return this.noQueryOrder.set(newState);
}
+ /**
+ * @param newOpv the proposed new value of the on parent version attribute (cannot be <code>null</code>)
+ * @return <code>true</code> if the value was changed
+ */
public boolean setOnParentVersion( OnParentVersion newOpv ) {
if (this.opv != newOpv) {
this.opv = newOpv;
@@ -196,6 +247,10 @@
return false;
}
+ /**
+ * @param newState the proposed new state of the protected attribute (cannot be <code>null</code>)
+ * @return <code>true</code> if the state was changed
+ */
public boolean setProtected( AttributeState.Value newState ) {
return this.notDeletable.set(newState);
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyType.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyType.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyType.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -9,23 +9,84 @@
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.modeshape.jcr.Messages;
+import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+/**
+ * The type property of a property definition.
+ */
public enum PropertyType implements CndElement {
+ /**
+ * The property value is a UTF-8 encoded string.
+ */
BINARY(javax.jcr.PropertyType.BINARY),
+
+ /**
+ * The property value is any string that can be converted via {@link Boolean#valueOf(String)}, such as ÒtrueÓ, ÒfalseÓ, Ò0Ó,
+ * Ò1Ó.
+ */
BOOLEAN(javax.jcr.PropertyType.BOOLEAN),
+
+ /**
+ * The property value is a valid date in ISO 8601:2000-compliant format: sYYYY-MM-DDThh:mm:ss.sssTZD.
+ */
DATE(javax.jcr.PropertyType.DATE),
+
+ /**
+ * The property value is a decimal number.
+ */
DECIMAL(javax.jcr.PropertyType.DECIMAL),
+
+ /**
+ * The property value is a double number.
+ */
DOUBLE(javax.jcr.PropertyType.DOUBLE),
+
+ /**
+ * The property value is a long number.
+ */
LONG(javax.jcr.PropertyType.LONG),
+
+ /**
+ * The property value is a valid JCR local name, fully qualified with namespace prefix.
+ */
NAME(javax.jcr.PropertyType.NAME),
+
+ /**
+ * The property value is a valid JCR path whose namespace prefixes are all registered correctly. The path does not have to point
+ * to an existing node.
+ */
PATH(javax.jcr.PropertyType.PATH),
+
+ /**
+ * The property value is a valid JCR identifier.
+ */
REFERENCE(javax.jcr.PropertyType.REFERENCE),
+
+ /**
+ * The property value is a string.
+ */
STRING(javax.jcr.PropertyType.STRING),
+
+ /**
+ * The property value is any string. The value is automatically converted to the appropriate type of the property when created.
+ */
UNDEFINED(javax.jcr.PropertyType.UNDEFINED),
+
+ /**
+ * The property value is a URI string.
+ */
URI(javax.jcr.PropertyType.URI),
+
+ /**
+ * The property value is a UTF-8 encoded string.
+ */
VARIANT(-1),
+
+ /**
+ * The property value is a JCR identifier.
+ */
WEAKREFERENCE(javax.jcr.PropertyType.WEAKREFERENCE);
/**
@@ -33,32 +94,52 @@
*/
public static final PropertyType DEFAULT_VALUE = PropertyType.STRING;
+ /**
+ * The value prefixing the CND notation of the type.
+ */
public static final String NOTATION_PREFIX = "("; //$NON-NLS-1$
+ /**
+ * The value suffixing the CND notation of the type.
+ */
public static final String NOTATION_SUFFIX = ")"; //$NON-NLS-1$
+ /**
+ * The shortened value for the {@link #UNDEFINED} type.
+ */
public static final String UNDEFINED_ADDITIONAL_NOTATION = "*"; //$NON-NLS-1$
- public static PropertyType find( String value ) {
- if (UNDEFINED_ADDITIONAL_NOTATION.equals(value)) {
+ /**
+ * @param cndNotation the CND notation of the property type being requested (cannot be <code>null</code> or empty)
+ * @return the property type (never <code>null</code>)
+ */
+ public static PropertyType find( final String cndNotation ) {
+ Utils.verifyIsNotEmpty(cndNotation, "cndNotation"); //$NON-NLS-1$
+
+ if (UNDEFINED_ADDITIONAL_NOTATION.equals(cndNotation)) {
return UNDEFINED;
}
- for (PropertyType type : PropertyType.values()) {
+ for (final PropertyType type : PropertyType.values()) {
if (PropertyType.VARIANT == type) {
continue;
}
- if (type.toString().equalsIgnoreCase(value)) {
+ if (type.toString().equalsIgnoreCase(cndNotation)) {
return type;
}
}
- throw new IllegalArgumentException(NLS.bind(Messages.invalidFindRequest, value));
+ throw new IllegalArgumentException(NLS.bind(Messages.invalidFindRequest, cndNotation));
}
- public static PropertyType findUsingJcrValue( int propertyType ) {
- for (PropertyType type : PropertyType.values()) {
+ /**
+ * @param propertyType the {@link javax.jcr.PropertyType} of the type being requested
+ * @return the property type (never <code>null</code>
+ * @throws IllegalArgumentException if an invalid input value
+ */
+ public static PropertyType findUsingJcrValue( final int propertyType ) {
+ for (final PropertyType type : PropertyType.values()) {
if (type.asJcrValue() == propertyType) {
return type;
}
@@ -67,13 +148,16 @@
throw new IllegalArgumentException(NLS.bind(Messages.invalidFindUsingJcrValueRequest, propertyType));
}
+ /**
+ * @return a collection of all the valid CND notations (never <code>null</code> or empty)
+ */
public static String[] validValues() {
- PropertyType[] allTypes = PropertyType.values();
+ final PropertyType[] allTypes = PropertyType.values();
// add one for additional undefined notation added later but subtract one for variant
- String[] result = new String[allTypes.length];
+ final String[] result = new String[allTypes.length];
int i = 0;
- for (PropertyType type : allTypes) {
+ for (final PropertyType type : allTypes) {
if (type != VARIANT) {
result[i++] = type.toString();
}
@@ -85,10 +169,15 @@
private final int jcrValue;
- private PropertyType( int propertyType ) {
+ private PropertyType( final int propertyType ) {
this.jcrValue = propertyType;
}
+ /**
+ * If variant, will return <code>-1</code> which is not a valid {@link javax.jcr.PropertyType}.
+ *
+ * @return the {@link javax.jcr.PropertyType} of the type
+ */
public int asJcrValue() {
return this.jcrValue;
}
@@ -99,13 +188,17 @@
* @see org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- public String toCndNotation( NotationType notationType ) {
- StringBuilder builder = new StringBuilder(NOTATION_PREFIX);
+ public String toCndNotation( final NotationType notationType ) {
+ final StringBuilder builder = new StringBuilder(NOTATION_PREFIX);
if (this == VARIANT) {
builder.append(AttributeState.VARIANT_CHAR);
} else {
- builder.append(toString());
+ if ((this == UNDEFINED) && (NotationType.LONG != notationType)) {
+ builder.append(UNDEFINED_ADDITIONAL_NOTATION);
+ } else {
+ builder.append(toString());
+ }
}
return builder.append(NOTATION_SUFFIX).toString();
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyValue.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyValue.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyValue.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -29,26 +29,33 @@
*/
public class PropertyValue implements Value {
- private int type;
+ private final int type;
private String value;
- public PropertyValue( int jcrType ) {
+ /**
+ * @param jcrType the {@link PropertyType} used to create the value
+ */
+ public PropertyValue( final int jcrType ) {
this.type = jcrType;
}
- public PropertyValue( int jcrType,
- String initialValue ) {
+ /**
+ * @param jcrType the {@link PropertyType} used to create the value
+ * @param initialValue the initial property value (can be <code>null</code> or empty)
+ */
+ public PropertyValue( final int jcrType,
+ final String initialValue ) {
this(jcrType);
this.value = initialValue;
}
/**
* {@inheritDoc}
- *
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals( Object obj ) {
+ public boolean equals( final Object obj ) {
if ((obj == null) || !getClass().equals(obj.getClass())) {
return false;
}
@@ -57,7 +64,7 @@
return true;
}
- PropertyValue that = (PropertyValue)obj;
+ final PropertyValue that = (PropertyValue)obj;
return (Utils.equals(this.type, that.type) && Utils.equals(this.value, that.value));
}
@@ -106,8 +113,8 @@
* @see javax.jcr.Binary#read(byte[], long)
*/
@Override
- public int read( byte[] b,
- long position ) throws IOException {
+ public int read( final byte[] b,
+ final long position ) throws IOException {
if (getSize() <= position) {
return -1;
}
@@ -121,7 +128,7 @@
long skip = position;
while (skip > 0) {
- long skipped = stream.skip(skip);
+ final long skipped = stream.skip(skip);
if (skipped <= 0) {
return -1;
@@ -131,19 +138,19 @@
}
return stream.read(b);
- } catch (IOException e) {
+ } catch (final IOException e) {
error = e;
throw e;
} finally {
if (stream != null) {
try {
stream.close();
- } catch (RuntimeException t) {
+ } catch (final RuntimeException t) {
// Only throw if we've not already thrown an exception ...
if (error == null) {
throw t;
}
- } catch (IOException t) {
+ } catch (final IOException t) {
// Only throw if we've not already thrown an exception ...
if (error == null) {
throw t;
@@ -184,14 +191,14 @@
public Calendar getDate() throws ValueFormatException {
try {
// TODO how do you determine the format here
- SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss"); //$NON-NLS-1$
- Calendar cal = Calendar.getInstance();
- Date d1 = df.parse(this.value);
+ final SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss"); //$NON-NLS-1$
+ final Calendar cal = Calendar.getInstance();
+ final Date d1 = df.parse(this.value);
cal.setTime(d1);
return cal;
- } catch (Exception e) {
- String from = PropertyType.nameFromValue(getType());
- String to = PropertyType.nameFromValue(PropertyType.LONG);
+ } catch (final Exception e) {
+ final String from = PropertyType.nameFromValue(getType());
+ final String to = PropertyType.nameFromValue(PropertyType.LONG);
throw new ValueFormatException(RestClientI18n.unableToConvertValue.text(this.value, from, to), e);
}
}
@@ -205,10 +212,10 @@
public BigDecimal getDecimal() throws ValueFormatException {
try {
return new BigDecimal(this.value);
- } catch (NumberFormatException t) {
- String from = PropertyType.nameFromValue(getType());
- String to = PropertyType.nameFromValue(PropertyType.DECIMAL);
- throw new ValueFormatException(RestClientI18n.unableToConvertValue.text(value, from, to), t);
+ } catch (final NumberFormatException t) {
+ final String from = PropertyType.nameFromValue(getType());
+ final String to = PropertyType.nameFromValue(PropertyType.DECIMAL);
+ throw new ValueFormatException(RestClientI18n.unableToConvertValue.text(this.value, from, to), t);
}
}
@@ -221,10 +228,10 @@
public double getDouble() throws ValueFormatException {
try {
return Double.parseDouble(this.value);
- } catch (NumberFormatException t) {
- String from = PropertyType.nameFromValue(getType());
- String to = PropertyType.nameFromValue(PropertyType.DOUBLE);
- throw new ValueFormatException(RestClientI18n.unableToConvertValue.text(value, from, to), t);
+ } catch (final NumberFormatException t) {
+ final String from = PropertyType.nameFromValue(getType());
+ final String to = PropertyType.nameFromValue(PropertyType.DOUBLE);
+ throw new ValueFormatException(RestClientI18n.unableToConvertValue.text(this.value, from, to), t);
}
}
@@ -237,10 +244,10 @@
public long getLong() throws ValueFormatException {
try {
return Long.parseLong(this.value);
- } catch (NumberFormatException t) {
- String from = PropertyType.nameFromValue(getType());
- String to = PropertyType.nameFromValue(PropertyType.LONG);
- throw new ValueFormatException(RestClientI18n.unableToConvertValue.text(value, from, to), t);
+ } catch (final NumberFormatException t) {
+ final String from = PropertyType.nameFromValue(getType());
+ final String to = PropertyType.nameFromValue(PropertyType.LONG);
+ throw new ValueFormatException(RestClientI18n.unableToConvertValue.text(this.value, from, to), t);
}
}
@@ -278,7 +285,7 @@
/**
* {@inheritDoc}
- *
+ *
* @see java.lang.Object#hashCode()
*/
@Override
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Protected.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Protected.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Protected.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -9,8 +9,15 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+/**
+ * The protected attribute used by property definitions and child node definitions. Protected properties cannot be removed from
+ * their parent node unless the parent node is deleted.
+ */
public class Protected extends AttributeState {
+ /**
+ * The CND notation for each notation type.
+ */
public static final String[] NOTATION = new String[] { "protected", "pro", "p" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/QueryOperators.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/QueryOperators.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/QueryOperators.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -18,21 +18,60 @@
import org.jboss.tools.modeshape.jcr.cnd.attributes.QueryOperators.QueryOperator;
/**
- *
+ * The primary item attribute used by property definitions.
*/
public final class QueryOperators extends ListAttributeState<QueryOperator> {
+ /**
+ * The CND notation for each notation type.
+ */
public static final String[] NOTATION = new String[] { "queryops", "qop", "qop" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ /**
+ * The valid query operators.
+ */
public enum QueryOperator implements CndElement {
+
+ /**
+ * The equals sign.
+ */
EQUALS("=", QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO), //$NON-NLS-1$
+
+ /**
+ * The greater than sign.
+ */
GREATER_THAN(">", QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO), //$NON-NLS-1$
+
+ /**
+ * The greater than or equal to sign.
+ */
GREATER_THAN_EQUALS(">=", QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO), //$NON-NLS-1$
+
+ /**
+ * The less than sign.
+ */
LESS_THAN("<", QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO), //$NON-NLS-1$
+
+ /**
+ * The less than or equal to sign.
+ */
LESS_THAN_EQUALS("<=", QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO), //$NON-NLS-1$
+
+ /**
+ * The LIKE sign.
+ */
LIKE("LIKE", QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO), //$NON-NLS-1$
+
+ /**
+ * The not equals sign.
+ */
NOT_EQUALS("<>", QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO); //$NON-NLS-1$
+ /**
+ * @param notation the operator's CND notation (cannot be <code>null</code> or empty)
+ * @return the query operator (never <code>null</code>)
+ * @throws IllegalArgumentException if an invalid CND notation
+ */
public static QueryOperator find( String notation ) {
for (QueryOperator operator : QueryOperator.values()) {
if (operator.notation.equals(notation)) {
@@ -43,6 +82,11 @@
throw new IllegalArgumentException(NLS.bind(Messages.invalidFindRequest, notation));
}
+ /**
+ * @param jcrValue the {@link QueryObjectModelConstants} value of the query operator (cannot be <code>null</code> or empty)
+ * @return the query operator (never <code>null</code>)
+ * @throws IllegalArgumentException if an invalid JCR value
+ */
public static QueryOperator findUsingJcrValue( String jcrValue ) {
for (QueryOperator operator : QueryOperator.values()) {
if (operator.asJcrValue().equals(jcrValue)) {
@@ -62,6 +106,9 @@
this.jcrValue = jcrValue;
}
+ /**
+ * @return the {@link QueryObjectModelConstants} value (never <code>null</code> or empty)
+ */
public String asJcrValue() {
return this.jcrValue;
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Queryable.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Queryable.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Queryable.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -10,12 +10,24 @@
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+/**
+ * The queryable attribute used by child node definitions.
+ */
public class Queryable extends AttributeState {
+ /**
+ * The CND notation for each notation type for when queryable.
+ */
public static final String[] QUERY_NOTATION = new String[] { "query", "q", "q" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ /**
+ * The CND notation for each notation type for when not queryable..
+ */
public static final String[] NO_QUERY_NOTATION = new String[] { "noquery", "nq", "nq" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ /**
+ * Constructs a queryable attribute set to be a variant (the default).
+ */
public Queryable() {
set(Value.VARIANT);
}
@@ -23,16 +35,6 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#hasCndNotation()
- */
- @Override
- protected boolean hasCndNotation() {
- return !isVariant();
- }
-
- /**
- * {@inheritDoc}
- *
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
*/
@Override
@@ -84,4 +86,14 @@
return Utils.EMPTY_STRING;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#hasCndNotation()
+ */
+ @Override
+ protected boolean hasCndNotation() {
+ return !isVariant();
+ }
+
}
\ No newline at end of file
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypes.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypes.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypes.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -12,12 +12,18 @@
import org.jboss.tools.modeshape.jcr.Utils;
/**
- *
+ * The required types of a child node definition.
*/
public final class RequiredTypes extends ListAttributeState<String> {
+ /**
+ * The CND list prefix.
+ */
public static final String NOTATION_PREFIX = "("; //$NON-NLS-1$;
+ /**
+ * The CND list suffix.
+ */
public static final String NOTATION_SUFFIX = ")"; //$NON-NLS-1$
/**
@@ -26,7 +32,7 @@
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getCndNotationPrefix(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- protected String getCndNotationPrefix( NotationType notationType ) {
+ protected String getCndNotationPrefix( final NotationType notationType ) {
return NOTATION_PREFIX;
}
@@ -36,35 +42,38 @@
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getCndNotationSuffix(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- protected String getCndNotationSuffix( NotationType notationType ) {
+ protected String getCndNotationSuffix( final NotationType notationType ) {
return NOTATION_SUFFIX;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getListPrefixEndDelimiter()
+ */
+ @Override
+ protected String getListPrefixEndDelimiter() {
+ return Utils.EMPTY_STRING;
+ }
+
+ /**
+ * @return the collection of required types (never <code>null</code>)
+ */
public String[] toArray() {
- List<String> typeNames = getSupportedItems();
+ final List<String> typeNames = getSupportedItems();
if (Utils.isEmpty(typeNames)) {
return Utils.EMPTY_STRING_ARRAY;
}
- String[] result = new String[typeNames.size()];
+ final String[] result = new String[typeNames.size()];
int i = 0;
- for (String typeName : typeNames) {
+ for (final String typeName : typeNames) {
result[i++] = typeName;
}
return result;
}
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getDelimiter()
- */
- @Override
- protected String getDelimiter() {
- return Utils.EMPTY_STRING;
- }
-
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SameNameSiblings.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SameNameSiblings.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SameNameSiblings.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -9,8 +9,14 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+/**
+ * The same named siblings attribute used by child node definitions.
+ */
public class SameNameSiblings extends AttributeState {
+ /**
+ * The CND notation for each notation type.
+ */
public static final String[] NOTATION = new String[] { "sns", "*", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypes.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypes.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypes.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -16,6 +16,9 @@
*/
public final class SuperTypes extends ListAttributeState<String> {
+ /**
+ * The CND list suffix.
+ */
public static final String NOTATION_PREFIX = ">"; //$NON-NLS-1$
/**
@@ -24,21 +27,24 @@
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getCndNotationPrefix(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- protected String getCndNotationPrefix( NotationType notationType ) {
+ protected String getCndNotationPrefix( final NotationType notationType ) {
return NOTATION_PREFIX;
}
+ /**
+ * @return the collection of super types (never <code>null</code>)
+ */
public String[] toArray() {
- List<String> superTypes = getSupportedItems();
+ final List<String> superTypes = getSupportedItems();
if (Utils.isEmpty(superTypes)) {
return Utils.EMPTY_STRING_ARRAY;
}
- String[] result = new String[superTypes.size()];
+ final String[] result = new String[superTypes.size()];
int i = 0;
- for (String superType : superTypes) {
+ for (final String superType : superTypes) {
result[i++] = superType;
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ValueConstraints.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ValueConstraints.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ValueConstraints.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -12,10 +12,13 @@
import org.jboss.tools.modeshape.jcr.Utils;
/**
- *
+ * The value constraints of a property definition.
*/
public final class ValueConstraints extends ListAttributeState<String> {
+ /**
+ * The CND list suffix.
+ */
public static final String NOTATION_PREFIX = "<"; //$NON-NLS-1$
/**
@@ -24,21 +27,24 @@
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getCndNotationPrefix(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
*/
@Override
- protected String getCndNotationPrefix( NotationType notationType ) {
+ protected String getCndNotationPrefix( final NotationType notationType ) {
return NOTATION_PREFIX;
}
+ /**
+ * @return the collection of value constraints (never <code>null</code>)
+ */
public String[] toArray() {
- List<String> constraints = getSupportedItems();
+ final List<String> constraints = getSupportedItems();
if (Utils.isEmpty(constraints)) {
return Utils.EMPTY_STRING_ARRAY;
}
- String[] result = new String[constraints.size()];
+ final String[] result = new String[constraints.size()];
int i = 0;
- for (String constraint : constraints) {
+ for (final String constraint : constraints) {
result[i++] = constraint;
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties 2012-03-05 19:30:11 UTC (rev 39293)
@@ -12,58 +12,97 @@
childDefinitionName = child node definition name
cndHasNoNamespacesOrNodeTypeDefinitions = CND has no namespace mappings or node type definitions.
+# 0 = child node definition name
defaultTypeExistsButMarkedAsVariant = Child node definition "{0}" has default type marked as a variant but has a default type.
defaultTypeName = default type name
defaultValue = default value
+# 0 = property definition name
defaultValuesExistButMarkedAsVariant = Property definition "{0}" has default values marked as a variant but has one or more default values.
+# 0 = node type name, 1 = property definition name
duplicateChildNodeDefinitionName = There are multiple child node definitions with a name of "{1}" in node type definition "{0}."
+# 0 = duplicate default value, 1 = property definition name
duplicateDefaultValue = There are multiple default values of "{1}" in property definition "{0}."
+# 0 = prefix
duplicateNamespacePrefix = There are multiple namespaces with a prefix of "{0}."
+# 0 = URI
duplicateNamespaceUri = There are multiple namespaces with a URI of "{0}."
+# 0 = node type definition name
duplicateNodeTypeDefinitionName = There are multiple node type definitions with the name of "{0}."
+# 0 = property definition name, 1 = node type definition name
duplicatePropertyDefinitionName = There are multiple property definitions with a name of "{1}" in node type definition "{0}."
+# 0 = property definition name, 1 = query operator
duplicateQueryOperator = There are multiple query operators of "{1}" in property definition "{0}."
+# 0 = child node definition name, 1 = duplicate required type name
duplicateRequiredType = There are multiple required types with a name of "{1}" in child node definition "{0}."
+# 0 = node type definition name, 1 = duplicate super type name
duplicateSuperType = There are multiple super types with a name of "{1}" in node type definition "{0}."
+# 0 = property definition name, 1 = duplicate value constraint
duplicateValueConstraint = There are multiple value constraints of "{1}" in property definition "{0}."
+# 0 = property definition name
emptyDefaultValues = The property definition "{0}" must have at least one default value.
+# 0 = name
emptyLocalName = The "{0}" must have a value.
emptyQueryOperator = The query operator is empty.
+# 0 = property definition name
emptyQueryOperators = The property definition "{0}" must have at least one query operator.
+# 0 = child node definition name
emptyRequiredTypes = The child node definition "{0}" must have at least one required type.
+# 0 = node type definition name
emptySuperTypes = The node type definition "{0}" must have at least one super type.
+# 0 = property or attribute name of a node type definition, property definition, or child node definition
emptyValue = A "{0}" value cannot be empty
+# 0 = property definition name
emptyValueConstraints = The property definition "{0}" must have at least one value constraint.
-errorImportingCndContent = Error importing {0}: {1}
+# 0 = property value, 1 = property type, 2 = property name
errorValidatingPropertyValueForType = An unexpected error occurred validating value "{0}" of type "{1}" of property "{2}."
+# 0 = parser token value, 1 = CND line number, 2 = CND column number
expectedNamespaceOrNodeDefinition = Expected either a namespace mapping or a node type defininition, but found {0} at line {1}, column {2}
-expectedValidQueryOperator = Expected a valid query operator ('=', '<>', '<', '<=', '>', '>=', or 'LIKE'), but was {0}
+# 0 = invalid input value
invalidFindRequest = The "find" method cannot be used for a value of "{0}."
+# 0 = invalid input value
invalidFindUsingJcrValueRequest = The "findUsingJcrValue" method cannot be used for a value of "{0}."
+# 0 = property definition name
invalidGetStateRequest = The "getState" method cannot be used for property "{0}."
-invalidQueryOperator = "{0}" is not a valid query operator.
+# 0 = invalid query operator
+invalidQueryOperator = Expected a valid query operator ('=', '<>', '<', '<=', '>', '>=', or 'LIKE'), but was "{0}."
+# 0 = property value, 1 = property type, 2 = property definition name
invalidPropertyValueForType = The value "{0}" is not valid for a "{1}" property type in property "{2}."
+# 0 = URI value
invalidUri = "{0}" is not a valid URI.
+# 0 = a name
localNameEqualToSelfOrParent = The "{0}" cannot be equal to self (dot) or parent (dot dot).
+# 0 = property or attribute name
localNameHasInvalidCharacters = The "{0}" contains invalid characters.
missingName = <missing name>
+# 0 = property definition name
multipleDefaultValuesForSingleValuedProperty = The single-valued property definition "{0}" cannot have multiple default values.
+# = CND line number, 1 = CND column number
multipleKeywordNotValidInJcr2CndFormat = The 'MULTIPLE' attribute at line {0}, column {1} is no longer valid in the JCR 2.0 CND format. Use 'SNS' instead.
namespacePrefix = namespace prefix
namespaceUri = namespace URI
+# 0 = node type definition name
nodeTypeDefinitionHasNoPropertyDefinitionsOrChildNodeDefinitions = The node type definition "{0}" has no property definitions or child node definitions.
nodeTypeDefinitionName = node type definition name
+# 0 = name of object
objectIsNull = Object {0} is null
okValidationMsg = There are no validation errors.
+# 0 = node type definition name
primaryItemExistsButMarkedAsVariant = Node type definition "{0}" has primary item marked as a variant but has a primary item.
primaryItemName = primary item name
+# 0 = CND line number, 1 = CND column number
primaryKeywordNotValidInJcr2CndFormat = The 'PRIMARY' attribute at line {0}, column {1} is no longer valid in the JCR 2.0 CND format. Only child node definitions can be a primary item.
propertyDefinitionName = property definition name
+# 0 = property definition name
queryOperatorsExistButMarkedAsVariant = Property definition "{0}" has query operators marked as a variant but has one or more query operators.
requiredTypeName = required type name
+# child node definition name
requiredTypesExistButMarkedAsVariant = Child node definition "{0}" has required types marked as a variant but has one or more required types.
+# 0 = name of string
stringIsEmpty = String {0} is empty
superTypeName = super type name
+# 0 = node type definition name
superTypesExistButMarkedAsVariant = Node type definition "{0}" has super types marked as a variant but has one or more super types.
+# 0 = property definition name
valueConstraintsExistButMarkedAsVariant = Property definition "{0}" has value constraints marked as a variant but has one or more value constraints.
+# 0 = CND line number, CND column number
vendorBlockWasNotClosed = Vendor block at line {0}, column {1} was not closed
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java 2012-03-05 18:50:32 UTC (rev 39292)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java 2012-03-05 19:30:11 UTC (rev 39293)
@@ -42,9 +42,9 @@
String AUTOCREATED_VARIANT_COMPRESSED_FORM = Autocreated.NOTATION[NotationType.COMPRESSED_INDEX] + VARIANT;
String AUTOCREATED_VARIANT_LONG_FORM = Autocreated.NOTATION[NotationType.LONG_INDEX] + VARIANT;
- String DEFAULT_TYPE_VARIANT_FORM = DefaultType.NOTATION + ' ' + VARIANT;
+ String DEFAULT_TYPE_VARIANT_FORM = DefaultType.NOTATION + VARIANT;
String DEFAULT_TYPE = "jcr:data"; //$NON-NLS-1$
- String DEFAULT_TYPE_TYPE_FORM = DefaultType.NOTATION + ' ' + DEFAULT_TYPE;
+ String DEFAULT_TYPE_TYPE_FORM = DefaultType.NOTATION + DEFAULT_TYPE;
String MANDATORY_VARIANT_COMPACT_FORM = Mandatory.NOTATION[NotationType.COMPACT_INDEX] + VARIANT;
String MANDATORY_VARIANT_COMPRESSED_FORM = Mandatory.NOTATION[NotationType.COMPRESSED_INDEX] + VARIANT;
@@ -96,17 +96,23 @@
String QUERY_OPS_ONE_OPERATOR_COMPRESSED_FORM = QUERY_OPS_COMPRESSED_FORM + " '" //$NON-NLS-1$
+ OPERATOR_ONE.toCndNotation(NotationType.COMPRESSED) + '\'';
String QUERY_OPS_ONE_OPERATOR_LONG_FORM = QUERY_OPS_LONG_FORM + " '" + OPERATOR_ONE.toCndNotation(NotationType.LONG) + '\''; //$NON-NLS-1$
- String QUERY_OPS_THREE_OPERATOR_COMPACT_FORM = QUERY_OPS_COMPACT_FORM + " '" + OPERATOR_ONE.toCndNotation(NotationType.COMPACT) //$NON-NLS-1$
- + CndElement.LIST_DELIMITER + OPERATOR_TWO.toCndNotation(NotationType.COMPACT) + CndElement.LIST_DELIMITER
+ String QUERY_OPS_THREE_OPERATOR_COMPACT_FORM = QUERY_OPS_COMPACT_FORM
+ + " '" + OPERATOR_ONE.toCndNotation(NotationType.COMPACT) //$NON-NLS-1$
+ + CndNotationPreferences.Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER + OPERATOR_TWO.toCndNotation(NotationType.COMPACT)
+ + CndNotationPreferences.Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER
+ OPERATOR_THREE.toCndNotation(NotationType.COMPACT) + '\'';
String QUERY_OPS_THREE_OPERATOR_COMPRESSED_FORM = QUERY_OPS_COMPRESSED_FORM
+ " '" //$NON-NLS-1$
- + OPERATOR_ONE.toCndNotation(NotationType.COMPRESSED) + CndElement.LIST_DELIMITER
- + OPERATOR_TWO.toCndNotation(NotationType.COMPRESSED) + CndElement.LIST_DELIMITER
+ + OPERATOR_ONE.toCndNotation(NotationType.COMPRESSED)
+ + CndNotationPreferences.Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER
+ + OPERATOR_TWO.toCndNotation(NotationType.COMPRESSED)
+ + CndNotationPreferences.Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER
+ OPERATOR_THREE.toCndNotation(NotationType.COMPRESSED) + '\'';
- String QUERY_OPS_THREE_OPERATOR_LONG_FORM = QUERY_OPS_LONG_FORM + " '" + OPERATOR_ONE.toCndNotation(NotationType.LONG) //$NON-NLS-1$
- + CndElement.LIST_DELIMITER + OPERATOR_TWO.toCndNotation(NotationType.LONG) + CndElement.LIST_DELIMITER
- + OPERATOR_THREE.toCndNotation(NotationType.LONG) + '\'';
+ String QUERY_OPS_THREE_OPERATOR_LONG_FORM = QUERY_OPS_LONG_FORM
+ + " '" + OPERATOR_ONE.toCndNotation(NotationType.LONG) //$NON-NLS-1$
+ + CndNotationPreferences.Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER + OPERATOR_TWO.toCndNotation(NotationType.LONG)
+ + CndNotationPreferences.Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER + OPERATOR_THREE.toCndNotation(NotationType.LONG)
+ + '\'';
String SAME_NAME_SIBLINGS_VARIANT_COMPACT_FORM = SameNameSiblings.NOTATION[NotationType.COMPACT_INDEX] + VARIANT;
String SAME_NAME_SIBLINGS_VARIANT_COMPRESSED_FORM = SameNameSiblings.NOTATION[NotationType.COMPRESSED_INDEX] + VARIANT;
@@ -116,8 +122,8 @@
String ITEM_TWO = "item2"; //$NON-NLS-1$
String ITEM_THREE = "item3"; //$NON-NLS-1$
String ONE_ITEM_SINGLE_QUOTED_FORM = '\'' + ITEM_ONE + '\'';
- String THREE_ITEM_SINGLE_QUOTED_FORM = '\'' + ITEM_ONE + CndElement.LIST_DELIMITER + ITEM_TWO + CndElement.LIST_DELIMITER
- + ITEM_THREE + '\'';
+ String THREE_ITEM_SINGLE_QUOTED_FORM = '\'' + ITEM_ONE + CndNotationPreferences.Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER
+ + ITEM_TWO + CndNotationPreferences.Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER + ITEM_THREE + '\'';
String DEFAULT_VALUES_VARIANT = DefaultValues.NOTATION_PREFIX + ' ' + VARIANT;
String DEFAULT_VALUES_ONE_ITEM_FORM = DefaultValues.NOTATION_PREFIX + ' ' + ONE_ITEM_SINGLE_QUOTED_FORM;
More information about the jbosstools-commits
mailing list