Author: elvisisking
Date: 2012-03-14 17:11:58 -0400 (Wed, 14 Mar 2012)
New Revision: 39516
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/QualifiedName.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/QualifiedNameTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/jsr_283_builtins.cnd
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/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/ChildNodeDefinition.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/CndValidator.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.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/NamespaceMapping.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/PropertyDefinition.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/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/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/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/RequiredTypes.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/ChildNodeDefinitionTest.java
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/NodeTypeDefinitionTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypesTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/test/AllTests.java
Log:
JBIDE-10702 Editor for JCR Compact Node Definition (CND) files. Added QualifiedName to
business objects. Some code reorganizing.
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -141,6 +141,11 @@
public static String emptySuperTypes;
/**
+ * A message indicating the unqualified name part of a qualified name is empty. One
parameter, the name or type of qualified
+ * name, is required.
+ */
+ public static String emptyUnqualifiedName;
+ /**
* A message indicating a missing value was found. One parameter, a string
identifying what the value is, is required.
*/
public static String emptyValue;
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/MultiValidationStatus.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -15,6 +15,11 @@
*/
public class MultiValidationStatus extends ValidationStatus {
+ /**
+ * An OK multi-validation status with a standard, localized message.
+ */
+ public static MultiValidationStatus OK_STATUS = new MultiValidationStatus();
+
private final List<ValidationStatus> errors = new
ArrayList<ValidationStatus>();
private ValidationStatus primary = null;
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Utils.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -19,6 +19,11 @@
public final class Utils {
/**
+ * And empty object array.
+ */
+ public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
+
+ /**
* An empty string constant.
*/
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
@@ -29,11 +34,16 @@
public static final String[] EMPTY_STRING_ARRAY = new String[0];
/**
+ * A string with one space character.
+ */
+ public static final String SPACE_STRING = " "; //$NON-NLS-1$
+
+ /**
* @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
+ * @return <code>true</code> if text was appended
*/
public static boolean build( final StringBuilder builder,
final boolean addDelimiter,
@@ -142,27 +152,11 @@
}
/**
- * @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 ) {
- if ((name == null) || name.isEmpty()) {
- name = Utils.EMPTY_STRING;
- }
-
- if (object == null) {
- throw new IllegalArgumentException(NLS.bind(Messages.objectIsNull, name));
- }
- }
-
- /**
* @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$
+ Utils.verifyIsNotNull(items, "items"); //$NON-NLS-1$
final String result[] = new String[items.length];
int i = 0;
@@ -181,16 +175,32 @@
*/
public static void verifyIsNotEmpty( final String text,
String name ) {
- if ((name == null) || name.isEmpty()) {
- name = Utils.EMPTY_STRING;
- }
+ if (isEmpty(text)) {
+ if ((name == null) || name.isEmpty()) {
+ name = Utils.EMPTY_STRING;
+ }
- if (isEmpty(text)) {
throw new IllegalArgumentException(NLS.bind(Messages.stringIsEmpty, name));
}
}
/**
+ * @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 verifyIsNotNull( final Object object,
+ String name ) {
+ if (object == null) {
+ if ((name == null) || name.isEmpty()) {
+ name = Utils.EMPTY_STRING;
+ }
+
+ throw new IllegalArgumentException(NLS.bind(Messages.objectIsNull, name));
+ }
+ }
+
+ /**
* Don't allow construction.
*/
private Utils() {
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ValidationStatus.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -21,7 +21,7 @@
* @param message the validation message (cannot be <code>null</code> or
empty)
* @return the error validation message (never <code>null</code>)
*/
- public static ValidationStatus createErrorMessage( String message ) {
+ public static ValidationStatus createErrorMessage( final String message ) {
return new ValidationStatus(Severity.ERROR, message);
}
@@ -29,7 +29,7 @@
* @param message the validation message (cannot be <code>null</code> or
empty)
* @return the information validation message (never <code>null</code>)
*/
- public static ValidationStatus createInfoMessage( String message ) {
+ public static ValidationStatus createInfoMessage( final String message ) {
return new ValidationStatus(Severity.INFO, message);
}
@@ -37,7 +37,7 @@
* @param message the validation message (cannot be <code>null</code> or
empty)
* @return the OK validation message (never <code>null</code>)
*/
- public static ValidationStatus createOkMessage( String message ) {
+ public static ValidationStatus createOkMessage( final String message ) {
return new ValidationStatus(Severity.OK, message);
}
@@ -45,7 +45,7 @@
* @param message the validation message (cannot be <code>null</code> or
empty)
* @return the warning validation message (never <code>null</code>)
*/
- public static ValidationStatus createWarningMessage( String message ) {
+ public static ValidationStatus createWarningMessage( final String message ) {
return new ValidationStatus(Severity.WARNING, message);
}
@@ -63,8 +63,8 @@
* @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 ) {
+ protected ValidationStatus( final Severity severity,
+ final String message ) {
assert (severity != null) : "severity is null"; //$NON-NLS-1$
Utils.verifyIsNotEmpty(message, "message"); //$NON-NLS-1$
@@ -78,7 +78,7 @@
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
- public int compareTo( ValidationStatus that ) {
+ public int compareTo( final ValidationStatus that ) {
if ((this == that) || (this.severity == that.severity)) {
return getMessage().compareTo(that.getMessage());
}
@@ -202,8 +202,8 @@
* @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$
+ public boolean isMoreSevere( final Severity that ) {
+ Utils.verifyIsNotNull(that, "that"); //$NON-NLS-1$
if ((this == that) || (this == WARNING)) {
return false;
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinition.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinition.java 2012-03-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinition.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -9,8 +9,6 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
-import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.jcr.nodetype.NodeDefinitionTemplate;
@@ -29,54 +27,9 @@
/**
*
*/
-public class ChildNodeDefinition implements CndElement, NodeDefinitionTemplate {
+public class ChildNodeDefinition implements CndElement, Comparable,
NodeDefinitionTemplate {
/**
- * The property names whose <code>toString()</code> is used in {@link
PropertyChangeEvent}s.
- */
- public enum PropertyName {
- /**
- * The autocreated indicator.
- */
- AUTOCREATED,
-
- /**
- * The default type.
- */
- DEFAULT_TYPE,
-
- /**
- * The mandatory indicator.
- */
- MANDATORY,
-
- /**
- * The property name.
- */
- NAME,
-
- /**
- * The on parent version value.
- */
- ON_PARENT_VERSION,
-
- /**
- * The protected indicator.
- */
- PROTECTED,
-
- /**
- * The collection of required types.
- */
- REQUIRED_TYPES,
-
- /**
- * The supports same name siblings indicator.
- */
- SAME_NAME_SIBLINGS,
- }
-
- /**
* The prefix used in CND notation before the property definition.
*/
public static final String NOTATION_PREFIX = "+"; //$NON-NLS-1$
@@ -84,12 +37,12 @@
/**
* The node attributes (never <code>null</code>).
*/
- private NodeAttributes attributes;
+ private final NodeAttributes attributes;
/**
* The node default type (never <code>null</code>).
*/
- private DefaultType defaultType;
+ private final DefaultType defaultType;
/**
* The registered property change listeners (never <code>null</code>).
@@ -99,19 +52,19 @@
/**
* The node identifier (can be <code>null</code> or empty).
*/
- private final LocalName name;
+ private final QualifiedName name;
/**
* The node required types (never <code>null</code>).
*/
- private RequiredTypes requiredTypes;
+ private final RequiredTypes requiredTypes;
/**
* Constructs an instance set to all defaults.
*/
public ChildNodeDefinition() {
this.attributes = new NodeAttributes();
- this.name = new LocalName();
+ this.name = new QualifiedName();
this.defaultType = new DefaultType();
this.requiredTypes = new RequiredTypes();
this.listeners = new CopyOnWriteArrayList<PropertyChangeListener>();
@@ -121,8 +74,8 @@
* @param newListener the listener being added (cannot be
<code>null</code>)
* @return <code>true</code> if successfully added
*/
- public boolean addListener( PropertyChangeListener newListener ) {
- Utils.isNotNull(newListener, "newListener"); //$NON-NLS-1$
+ public boolean addListener( final PropertyChangeListener newListener ) {
+ Utils.verifyIsNotNull(newListener, "newListener"); //$NON-NLS-1$
return this.listeners.addIfAbsent(newListener);
}
@@ -133,8 +86,8 @@
* @param requiredTypeBeingAdded the required type being added (cannot be
<code>null</code>)
* @return <code>true</code> if added
*/
- public boolean addRequiredType( String requiredTypeBeingAdded ) {
- if (this.requiredTypes.add(requiredTypeBeingAdded)) {
+ public boolean addRequiredType( final String requiredTypeBeingAdded ) {
+ if (this.requiredTypes.add(QualifiedName.parse(requiredTypeBeingAdded))) {
notifyChangeListeners(PropertyName.REQUIRED_TYPES, null,
requiredTypeBeingAdded);
return true; // added
}
@@ -161,10 +114,10 @@
* @param newState the new attribute state (cannot be <code>null</code>)
* @return <code>true</code> if the attribute state was changed
*/
- public boolean changeState( PropertyName propertyName,
- Value newState ) {
- Utils.isNotNull(propertyName, "propertyName"); //$NON-NLS-1$
- Utils.isNotNull(newState, "newState"); //$NON-NLS-1$
+ public boolean changeState( final PropertyName propertyName,
+ final Value newState ) {
+ Utils.verifyIsNotNull(propertyName, "propertyName"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(newState, "newState"); //$NON-NLS-1$
Object oldValue = null;
Object newValue = newState;
@@ -211,7 +164,7 @@
* @return <code>true</code> if at least one required type was removed
*/
public boolean clearRequiredTypes() {
- List<String> oldValue = new
ArrayList<String>(requiredTypes.getSupportedItems());
+ final String[] oldValue = this.requiredTypes.toArray();
if (this.requiredTypes.clear()) {
notifyChangeListeners(PropertyName.REQUIRED_TYPES, oldValue, null);
@@ -224,23 +177,66 @@
/**
* {@inheritDoc}
*
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo( final Object object ) {
+ final ChildNodeDefinition that = (ChildNodeDefinition)object;
+ final String thisName = getName();
+ final String thatName = that.getName();
+
+ if (Utils.isEmpty(thisName)) {
+ if (Utils.isEmpty(thatName)) {
+ return 0;
+ }
+
+ // thatName is not empty
+ return 1;
+ }
+
+ // thisName is not empty
+ if (thatName == null) {
+ return 1;
+ }
+
+ // thisName and thatName are not empty
+ return thisName.compareTo(thatName);
+ }
+
+ /**
+ * @param notationType the notation type being requested (cannot be
<code>null</code>)
+ * @return the CND notation (never <code>null</code>)
+ */
+ public String getAttributesCndNotation( final NotationType notationType ) {
+ final String cndNotation = this.attributes.toCndNotation(notationType);
+
+ if (cndNotation == null) {
+ return Utils.EMPTY_STRING;
+ }
+
+ return cndNotation;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see javax.jcr.nodetype.ItemDefinition#getDeclaringNodeType()
+ * @throws UnsupportedOperationException if method is called
*/
@Override
public NodeType getDeclaringNodeType() {
- // TODO implement
- return null;
+ throw new UnsupportedOperationException();
}
/**
* {@inheritDoc}
*
* @see javax.jcr.nodetype.NodeDefinition#getDefaultPrimaryType()
+ * @throws UnsupportedOperationException if method is called
*/
@Override
public NodeType getDefaultPrimaryType() {
- // TODO implement
- return null;
+ throw new UnsupportedOperationException();
}
/**
@@ -250,7 +246,7 @@
*/
@Override
public String getDefaultPrimaryTypeName() {
- String primaryType = this.defaultType.getDefaultType();
+ final String primaryType = this.defaultType.getDefaultType();
// per API should return null if empty
if (Utils.isEmpty(primaryType)) {
@@ -296,6 +292,10 @@
return this.attributes.getOnParentVersion().asJcrValue();
}
+ private String getPrefixEndDelimiter() {
+ return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.CHILD_NODE_DEFINITION_END_PREFIX_DELIMITER);
+ }
+
/**
* {@inheritDoc}
*
@@ -310,14 +310,28 @@
* {@inheritDoc}
*
* @see javax.jcr.nodetype.NodeDefinition#getRequiredPrimaryTypes()
+ * @throws UnsupportedOperationException if method is called
*/
@Override
public NodeType[] getRequiredPrimaryTypes() {
- // TODO implement
- return null;
+ throw new UnsupportedOperationException();
}
/**
+ * @param notationType the notation type being requested (cannot be
<code>null</code>)
+ * @return the CND notation (never <code>null</code>)
+ */
+ public String getRequiredTypesCndNotation( final NotationType notationType ) {
+ final String cndNotation = this.requiredTypes.toCndNotation(notationType);
+
+ if (cndNotation == null) {
+ return Utils.EMPTY_STRING;
+ }
+
+ return cndNotation;
+ }
+
+ /**
* Can be used to find the attribute state of the autocreated, default type,
mandatory, protected, required types, same name
* siblings, and on parent version properties.
*
@@ -325,8 +339,8 @@
* @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 ) {
- Utils.isNotNull(propertyName, "propertyName"); //$NON-NLS-1$
+ public Value getState( final PropertyName propertyName ) {
+ Utils.verifyIsNotNull(propertyName, "propertyName"); //$NON-NLS-1$
if (PropertyName.AUTOCREATED == propertyName) {
return this.attributes.getAutocreated().get();
@@ -397,8 +411,8 @@
* @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 ) {
- Utils.isNotNull(propertyName, "propertyName"); //$NON-NLS-1$
+ public boolean isVariant( final PropertyName propertyName ) {
+ Utils.verifyIsNotNull(propertyName, "propertyName"); //$NON-NLS-1$
if (PropertyName.ON_PARENT_VERSION == propertyName) {
return (this.attributes.getOnParentVersion() == OnParentVersion.VARIANT);
@@ -415,12 +429,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);
}
@@ -431,8 +445,8 @@
* @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 ) {
- Utils.isNotNull(listener, "listener"); //$NON-NLS-1$
+ public boolean removeListener( final PropertyChangeListener listener ) {
+ Utils.verifyIsNotNull(listener, "listener"); //$NON-NLS-1$
return this.listeners.remove(listener);
}
@@ -443,8 +457,10 @@
* @param requiredTypeBeingRemoved the required type being removed (cannot be
<code>null</code>)
* @return <code>true</code> if removed
*/
- public boolean removeRequiredType( String requiredTypeBeingRemoved ) {
- if (this.requiredTypes.remove(requiredTypeBeingRemoved)) {
+ public boolean removeRequiredType( final String requiredTypeBeingRemoved ) {
+ final QualifiedName qname = QualifiedName.parse(requiredTypeBeingRemoved);
+
+ if (this.requiredTypes.remove(qname)) {
notifyChangeListeners(PropertyName.REQUIRED_TYPES, requiredTypeBeingRemoved,
null);
return true; // removed
}
@@ -458,8 +474,8 @@
* @see javax.jcr.nodetype.NodeDefinitionTemplate#setAutoCreated(boolean)
*/
@Override
- public void setAutoCreated( boolean newAutocreated ) {
- Value newState = (newAutocreated ? Value.IS : Value.IS_NOT);
+ public void setAutoCreated( final boolean newAutocreated ) {
+ final Value newState = (newAutocreated ? Value.IS : Value.IS_NOT);
changeState(PropertyName.AUTOCREATED, newState);
}
@@ -469,8 +485,8 @@
* @see
javax.jcr.nodetype.NodeDefinitionTemplate#setDefaultPrimaryTypeName(java.lang.String)
*/
@Override
- public void setDefaultPrimaryTypeName( String newTypeName ) {
- String oldValue = this.defaultType.getDefaultType();
+ public void setDefaultPrimaryTypeName( final String newTypeName ) {
+ final String oldValue = this.defaultType.getDefaultType();
if (this.defaultType.setDefaultType(newTypeName)) {
notifyChangeListeners(PropertyName.DEFAULT_TYPE, oldValue, newTypeName);
@@ -483,8 +499,8 @@
* @see javax.jcr.nodetype.NodeDefinitionTemplate#setMandatory(boolean)
*/
@Override
- public void setMandatory( boolean newMandatory ) {
- Value newState = (newMandatory ? Value.IS : Value.IS_NOT);
+ public void setMandatory( final boolean newMandatory ) {
+ final Value newState = (newMandatory ? Value.IS : Value.IS_NOT);
changeState(PropertyName.MANDATORY, newState);
}
@@ -494,8 +510,8 @@
* @see javax.jcr.nodetype.NodeDefinitionTemplate#setName(java.lang.String)
*/
@Override
- public void setName( String newName ) {
- Object oldValue = this.name.get();
+ public void setName( final String newName ) {
+ final Object oldValue = getName();
if (this.name.set(newName)) {
notifyChangeListeners(PropertyName.NAME, oldValue, newName);
@@ -508,8 +524,8 @@
* @see javax.jcr.nodetype.NodeDefinitionTemplate#setOnParentVersion(int)
*/
@Override
- public void setOnParentVersion( int newOpv ) {
- OnParentVersion oldValue = this.attributes.getOnParentVersion();
+ public void setOnParentVersion( final int newOpv ) {
+ final OnParentVersion oldValue = this.attributes.getOnParentVersion();
if
(this.attributes.setOnParentVersion(OnParentVersion.findUsingJcrValue(newOpv))) {
notifyChangeListeners(PropertyName.ON_PARENT_VERSION, oldValue, newOpv);
@@ -522,8 +538,8 @@
* @param newOpv the new OPV value (cannot be <code>null</code>)
* @return <code>true</code> if successfully changed
*/
- public boolean setOnParentVersion( String newOpv ) {
- OnParentVersion oldValue = this.attributes.getOnParentVersion();
+ public boolean setOnParentVersion( final String newOpv ) {
+ final OnParentVersion oldValue = this.attributes.getOnParentVersion();
if (this.attributes.setOnParentVersion(OnParentVersion.find(newOpv))) {
notifyChangeListeners(PropertyName.ON_PARENT_VERSION, oldValue, newOpv);
@@ -539,8 +555,8 @@
* @see javax.jcr.nodetype.NodeDefinitionTemplate#setProtected(boolean)
*/
@Override
- public void setProtected( boolean newProtected ) {
- Value newState = (newProtected ? Value.IS : Value.IS_NOT);
+ public void setProtected( final boolean newProtected ) {
+ final Value newState = (newProtected ? Value.IS : Value.IS_NOT);
changeState(PropertyName.PROTECTED, newState);
}
@@ -550,13 +566,13 @@
* @see
javax.jcr.nodetype.NodeDefinitionTemplate#setRequiredPrimaryTypeNames(java.lang.String[])
*/
@Override
- public void setRequiredPrimaryTypeNames( String[] newTypeNames ) {
- List<String> items = this.requiredTypes.getSupportedItems();
+ public void setRequiredPrimaryTypeNames( final String[] newTypeNames ) {
+ final String[] items = this.requiredTypes.toArray();
boolean changed = this.requiredTypes.clear();
if (!Utils.isEmpty(newTypeNames)) {
- for (String typeName : newTypeNames) {
- if (this.requiredTypes.add(typeName)) {
+ for (final String typeName : newTypeNames) {
+ if (this.requiredTypes.add(QualifiedName.parse(typeName))) {
changed = true;
}
}
@@ -573,8 +589,8 @@
* @see javax.jcr.nodetype.NodeDefinitionTemplate#setSameNameSiblings(boolean)
*/
@Override
- public void setSameNameSiblings( boolean newAllowSameNameSiblings ) {
- Value newState = (newAllowSameNameSiblings ? Value.IS : Value.IS_NOT);
+ public void setSameNameSiblings( final boolean newAllowSameNameSiblings ) {
+ final Value newState = (newAllowSameNameSiblings ? Value.IS : Value.IS_NOT);
changeState(PropertyName.SAME_NAME_SIBLINGS, newState);
}
@@ -584,16 +600,63 @@
* @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 StringBuilder builder = new StringBuilder(NOTATION_PREFIX);
+ builder.append(getPrefixEndDelimiter());
+
final String DELIM = getFormatDelimiter();
- StringBuilder builder = new StringBuilder();
- builder.append(NOTATION_PREFIX).append(this.name.toCndNotation(notationType));
- boolean addDelim = Utils.build(builder, false, DELIM,
this.requiredTypes.toCndNotation(notationType));
- addDelim = Utils.build(builder, addDelim, DELIM,
this.defaultType.toCndNotation(notationType));
- addDelim = Utils.build(builder, addDelim, DELIM,
this.attributes.toCndNotation(notationType));
+ builder.append(this.name.toCndNotation(notationType));
+ Utils.build(builder, true, DELIM,
this.requiredTypes.toCndNotation(notationType));
+ Utils.build(builder, true, DELIM, this.defaultType.toCndNotation(notationType));
+ Utils.build(builder, true, DELIM, this.attributes.toCndNotation(notationType));
return builder.toString();
}
+ /**
+ * The property names whose <code>toString()</code> is used in {@link
PropertyChangeEvent}s.
+ */
+ public enum PropertyName {
+ /**
+ * The autocreated indicator.
+ */
+ AUTOCREATED,
+
+ /**
+ * The default type.
+ */
+ DEFAULT_TYPE,
+
+ /**
+ * The mandatory indicator.
+ */
+ MANDATORY,
+
+ /**
+ * The property name.
+ */
+ NAME,
+
+ /**
+ * The on parent version value.
+ */
+ ON_PARENT_VERSION,
+
+ /**
+ * The protected indicator.
+ */
+ PROTECTED,
+
+ /**
+ * The collection of required types.
+ */
+ REQUIRED_TYPES,
+
+ /**
+ * The supports same name siblings indicator.
+ */
+ SAME_NAME_SIBLINGS,
+ }
+
}
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -62,7 +62,7 @@
* Constructs an importer that is not JCR 170 compatible.
*/
public CndImporter() {
- this.jcr170 = false;
+ this.jcr170 = true;
}
/**
@@ -130,7 +130,7 @@
* @throws ParsingException if there is a problem parsing the content
*/
public CompactNodeTypeDefinition parse( final String content ) {
- Utils.isNotNull(content, "content is null"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(content, "content is null"); //$NON-NLS-1$
final CompactNodeTypeDefinition cnd = new CompactNodeTypeDefinition();
final Tokenizer tokenizer = new CndTokenizer(false, false);
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndNotationPreferences.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -20,6 +20,84 @@
public class CndNotationPreferences {
/**
+ * Default preferences.
+ */
+ public static final CndNotationPreferences DEFAULT_PREFERENCES = new
CndNotationPreferences();
+
+ /**
+ * The preferences (never <code>null</code>).
+ */
+ private final Map<Preference, String> prefs;
+
+ /**
+ * Constructs default preferences.
+ */
+ private CndNotationPreferences() {
+ final Map<Preference, String> temp = new HashMap<Preference,
String>();
+ loadDefaults(temp);
+ this.prefs = Collections.unmodifiableMap(temp);
+ }
+
+ /**
+ * @param overrideValues the preferences whose values are being overridden (cannot be
<code>null</code>)
+ */
+ public CndNotationPreferences( final Map<Preference, String> overrideValues )
{
+ Utils.verifyIsNotNull(overrideValues, "overrideValues"); //$NON-NLS-1$
+
+ final Map<Preference, String> temp = new HashMap<Preference,
String>();
+ loadDefaults(temp);
+
+ if ((overrideValues != null) && !overrideValues.isEmpty()) {
+ for (final Entry<Preference, String> entry : overrideValues.entrySet())
{
+ temp.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ this.prefs = Collections.unmodifiableMap(temp);
+ }
+
+ /**
+ * @param pref the preference name whose value is being requested (cannot be
<code>null</code>)
+ * @return the preference value (never <code>null</code> but can be
empty)
+ */
+ public String get( final Preference pref ) {
+ Utils.verifyIsNotNull(pref, "pref"); //$NON-NLS-1$
+ return this.prefs.get(pref);
+ }
+
+ private void loadDefaults( final 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.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR, Utils.EMPTY_STRING);
+ map.put(Preference.CHILD_NODE_DEFINITION_DELIMITER, "\n");
//$NON-NLS-1$
+ map.put(Preference.CHILD_NODE_DEFINITION_END_PREFIX_DELIMITER, " ");
//$NON-NLS-1$
+ map.put(Preference.CHILD_NODE_PROPERTY_DELIMITER, Utils.SPACE_STRING);
+ map.put(Preference.DEFAULT_VALUES_END_PREFIX_DELIMITER, Utils.SPACE_STRING);
+ map.put(Preference.DEFAULT_VALUES_QUOTE_CHARACTER, "'");
//$NON-NLS-1$
+ map.put(Preference.DEFAULT_TYPE_END_PREFIX_DELIMITER, Utils.SPACE_STRING);
+ map.put(Preference.CHILD_NODE_DEFINITION_SECTION_END_DELIMITER,
Utils.EMPTY_STRING);
+ map.put(Preference.CHILD_NODE_DEFINITION_START_DELIMITER, "\t");
//$NON-NLS-1$
+ map.put(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER, Utils.SPACE_STRING);
+ map.put(Preference.ATTRIBUTE_LIST_QUOTE_CHAR, Utils.EMPTY_STRING);
+ map.put(Preference.NAMESPACE_MAPPING_DELIMITER, "\n"); //$NON-NLS-1$
+ map.put(Preference.NAMESPACE_MAPPING_SECTION_END_DELIMITER, "\n");
//$NON-NLS-1$
+ map.put(Preference.CHILD_NODE_ATTRIBUTES_DELIMITER, Utils.SPACE_STRING);
+ map.put(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER,
"\n"); //$NON-NLS-1$
+ map.put(Preference.NODE_TYPE_DEFINITION_DELIMITER, "\n");
//$NON-NLS-1$
+ map.put(Preference.NODE_TYPE_DEFINITION_NAME_END_DELIMITER, Utils.SPACE_STRING);
+ map.put(Preference.NODE_TYPE_DEFINITION_SECTION_END_DELIMITER, "\n");
//$NON-NLS-1$
+ map.put(Preference.PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER,
Utils.SPACE_STRING);
+ map.put(Preference.PROPERTY_DEFINITION_DELIMITER, "\n"); //$NON-NLS-1$
+ map.put(Preference.PROPERTY_DEFINITION_END_PREFIX_DELIMITER,
Utils.SPACE_STRING);
+ map.put(Preference.PROPERTY_DEFINITION_SECTION_END_DELIMITER,
Utils.EMPTY_STRING);
+ map.put(Preference.PROPERTY_DEFINITION_START_DELIMITER, "\t");
//$NON-NLS-1$
+ map.put(Preference.REQUIRED_TYPES_END_PREFIX_DELIMITER, Utils.EMPTY_STRING);
+ map.put(Preference.SUPER_TYPES_END_DELIMITER, Utils.SPACE_STRING);
+ map.put(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER, "'");
//$NON-NLS-1$
+ }
+
+ /**
* All preferences used during CND notation construction.
*/
public enum Preference {
@@ -30,6 +108,12 @@
ATTRIBUTE_LIST_ELEMENT_DELIMITER,
/**
+ * The string version of the quote character (empty string, single quote, or
double quote) surrounding each item in
+ * attribute lists.
+ */
+ ATTRIBUTE_LIST_ITEM_QUOTE_CHAR,
+
+ /**
* The delimiter after the prefix to attribute lists.
*/
ATTRIBUTE_LIST_PREFIX_END_DELIMITER,
@@ -50,16 +134,42 @@
CHILD_NODE_DEFINITION_DELIMITER,
/**
+ * The delimiter after the plus sign and before the child node definition name.
+ */
+ CHILD_NODE_DEFINITION_END_PREFIX_DELIMITER,
+
+ /**
* The delimiter after the last child node definition.
*/
CHILD_NODE_DEFINITION_SECTION_END_DELIMITER,
/**
+ * The delimiter before a child node definition.
+ */
+ CHILD_NODE_DEFINITION_START_DELIMITER,
+
+ /**
* The delimiter between child node properties.
*/
CHILD_NODE_PROPERTY_DELIMITER,
/**
+ * The delimiter after the equals sign and before the default type.
+ */
+ DEFAULT_TYPE_END_PREFIX_DELIMITER,
+
+ /**
+ * The delimiter after the equals sign and before the list of default values.
+ */
+ DEFAULT_VALUES_END_PREFIX_DELIMITER,
+
+ /**
+ * The string form of the quotation character used to surround the one or more
default values. Value can be either empty,
+ * the single quote, or the double quote.
+ */
+ DEFAULT_VALUES_QUOTE_CHARACTER,
+
+ /**
* The delimiter between namespace mappings.
*/
NAMESPACE_MAPPING_DELIMITER,
@@ -72,7 +182,7 @@
/**
* The delimiter between node type definition attributes.
*/
- NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER,
+ NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER,
/**
* The delimiter between node type definitions.
@@ -100,81 +210,34 @@
PROPERTY_DEFINITION_DELIMITER,
/**
+ * The delimiter after the dash and before the property definition name.
+ */
+ PROPERTY_DEFINITION_END_PREFIX_DELIMITER,
+
+ /**
* The delimiter after the last property definition.
*/
PROPERTY_DEFINITION_SECTION_END_DELIMITER,
/**
+ * The delimiter before a property definition.
+ */
+ PROPERTY_DEFINITION_START_DELIMITER,
+
+ /**
+ * The delimiter after the open paren and before the required types.
+ */
+ REQUIRED_TYPES_END_PREFIX_DELIMITER,
+
+ /**
* The delimiter after the last super type.
*/
SUPER_TYPES_END_DELIMITER,
- }
- /**
- * Default preferences.
- */
- public static final CndNotationPreferences DEFAULT_PREFERENCES = new
CndNotationPreferences();
-
- /**
- * The preferences (never <code>null</code>).
- */
- private final Map<Preference, String> prefs;
-
- /**
- * Constructs default preferences.
- */
- private CndNotationPreferences() {
- Map<Preference, String> temp = new HashMap<Preference, String>();
- loadDefaults(temp);
- this.prefs = Collections.unmodifiableMap(temp);
+ /**
+ * The string version of the quote character (empty string, single quote, or
double quote) surrounding each item in value
+ * constraints list.
+ */
+ VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER,
}
-
- /**
- * @param overrideValues the preferences whose values are being overridden (cannot be
<code>null</code>)
- */
- public CndNotationPreferences( Map<Preference, String> overrideValues ) {
- Utils.isNotNull(overrideValues, "overrideValues"); //$NON-NLS-1$
-
- Map<Preference, String> temp = new HashMap<Preference, String>();
- loadDefaults(temp);
-
- if ((overrideValues != null) && !overrideValues.isEmpty()) {
- for (Entry<Preference, String> entry : overrideValues.entrySet()) {
- temp.put(entry.getKey(), entry.getValue());
- }
- }
-
- this.prefs = Collections.unmodifiableMap(temp);
- }
-
- /**
- * @param pref the preference name whose value is being requested (cannot be
<code>null</code>)
- * @return the preference value (never <code>null</code> but can be
empty)
- */
- public String get( Preference pref ) {
- Utils.isNotNull(pref, "pref"); //$NON-NLS-1$
- return this.prefs.get(pref);
- }
-
- 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$
- map.put(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER, " ");
//$NON-NLS-1$
- map.put(Preference.ATTRIBUTE_LIST_QUOTE_CHAR, "'"); //$NON-NLS-1$
- map.put(Preference.NAMESPACE_MAPPING_DELIMITER, "\n"); //$NON-NLS-1$
- map.put(Preference.NAMESPACE_MAPPING_SECTION_END_DELIMITER, "\n");
//$NON-NLS-1$
- map.put(Preference.CHILD_NODE_ATTRIBUTES_DELIMITER, " ");
//$NON-NLS-1$
- map.put(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER, " ");
//$NON-NLS-1$
- map.put(Preference.NODE_TYPE_DEFINITION_DELIMITER, "\n");
//$NON-NLS-1$
- map.put(Preference.NODE_TYPE_DEFINITION_NAME_END_DELIMITER, " ");
//$NON-NLS-1$
- map.put(Preference.NODE_TYPE_DEFINITION_SECTION_END_DELIMITER, "\n");
//$NON-NLS-1$
- map.put(Preference.PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER, " ");
//$NON-NLS-1$
- map.put(Preference.PROPERTY_DEFINITION_DELIMITER, "\n"); //$NON-NLS-1$
- map.put(Preference.PROPERTY_DEFINITION_SECTION_END_DELIMITER, "\n");
//$NON-NLS-1$
- map.put(Preference.SUPER_TYPES_END_DELIMITER, "\n"); //$NON-NLS-1$
- }
}
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -36,7 +36,7 @@
public static ValidationStatus isValid( final String value,
final PropertyType propertyType,
final String propertyName ) {
- Utils.isNotNull(propertyType, "propertyType"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(propertyType, "propertyType"); //$NON-NLS-1$
if (Utils.isEmpty(value)) {
return ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyValue,
propertyName));
@@ -44,11 +44,11 @@
try {
if (PropertyType.STRING == propertyType) {
- return ValidationStatus.OK_STATUS;
+ return ValidationStatus.OK_STATUS; // always valid
}
if (PropertyType.BINARY == propertyType) {
- // TODO implement BINARY validation
+ return ValidationStatus.OK_STATUS; // always valid
} else if (PropertyType.BOOLEAN == propertyType) {
if (!value.equalsIgnoreCase(Boolean.TRUE.toString()) &&
!value.equalsIgnoreCase(Boolean.FALSE.toString())) {
return
ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, new
Object[] { value,
@@ -87,13 +87,13 @@
} else if (PropertyType.PATH == propertyType) {
// TODO implement PATH validation
} else if (PropertyType.REFERENCE == propertyType) {
- // TODO implement REFERENCE validation
+ return ValidationStatus.OK_STATUS; // always valid
} else if (PropertyType.UNDEFINED == propertyType) {
- // TODO implement UNDEFINED validation
+ return ValidationStatus.OK_STATUS; // always valid
} else if (PropertyType.URI == propertyType) {
return validateUri(value, propertyName);
} else if (PropertyType.WEAKREFERENCE == propertyType) {
- // TODO implement WEAKREFERENCE validation
+ return ValidationStatus.OK_STATUS; // always valid
}
return ValidationStatus.OK_STATUS;
@@ -125,7 +125,7 @@
* @return the status (never <code>null</code>)
*/
public static ValidationStatus validateChildNodeDefinition( final ChildNodeDefinition
childNodeDefinition ) {
- Utils.isNotNull(childNodeDefinition, "childNodeDefinition");
//$NON-NLS-1$
+ Utils.verifyIsNotNull(childNodeDefinition, "childNodeDefinition");
//$NON-NLS-1$
/**
* <pre>
@@ -212,11 +212,71 @@
}
/**
+ * @param nodeTypeName the node type name whose child node definitions are being
checked (cannot be <code>null</code> or empty)
+ * @param childNodeDefinitions the collection of a node type definition's child
node definitions to validate (can be
+ * <code>null</code> or empty)
+ * @return the status (never <code>null</code>)
+ */
+ public static MultiValidationStatus validateChildNodeDefinitions( final String
nodeTypeName,
+ final
List<ChildNodeDefinition> childNodeDefinitions ) {
+ Utils.verifyIsNotEmpty(nodeTypeName, "nodeTypeName"); //$NON-NLS-1$
+
+ /**
+ * <pre>
+ * ERROR - Duplicate child node definition names
+ * </pre>
+ */
+
+ // OK to have none
+ if (Utils.isEmpty(childNodeDefinitions)) {
+ return MultiValidationStatus.OK_STATUS;
+ }
+
+ final MultiValidationStatus status = new MultiValidationStatus();
+ final List<String> childNodeNames = new
ArrayList<String>(childNodeDefinitions.size());
+
+ for (final ChildNodeDefinition childNodeDefn : childNodeDefinitions) {
+ validateChildNodeDefinition(childNodeDefn, status);
+
+ { // ERROR - Duplicate child node definition names
+ final String childNodeName = childNodeDefn.getName();
+
+ if (!Utils.isEmpty(childNodeName)) {
+ if (childNodeNames.contains(childNodeName)) {
+
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateChildNodeDefinitionName,
+
nodeTypeName, childNodeName)));
+ } else {
+ childNodeNames.add(childNodeName);
+ }
+ }
+ }
+ }
+
+ return status;
+ }
+
+ /**
+ * @param nodeTypeName the node type name whose child node definitions are being
checked (cannot be <code>null</code> or empty)
+ * @param childNodeDefinitions the collection of a node type definition's child
node definitions 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 validateChildNodeDefinitions( final String nodeTypeName,
+ final
List<ChildNodeDefinition> childNodeDefinitions,
+ final MultiValidationStatus status )
{
+ final MultiValidationStatus newStatus =
validateChildNodeDefinitions(nodeTypeName, childNodeDefinitions);
+
+ if (!newStatus.isOk()) {
+ status.add(newStatus);
+ }
+ }
+
+ /**
* @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$
+ Utils.verifyIsNotNull(cnd, "cnd"); //$NON-NLS-1$
/**
* <pre>
@@ -325,7 +385,7 @@
* @return the status (never <code>null</code>)
*/
public static ValidationStatus validateNamespaceMapping( final NamespaceMapping
namespaceMapping ) {
- Utils.isNotNull(namespaceMapping, "namespaceMapping"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(namespaceMapping, "namespaceMapping");
//$NON-NLS-1$
/**
* <pre>
@@ -370,13 +430,12 @@
* </pre>
*/
- final MultiValidationStatus status = new MultiValidationStatus();
-
// OK not to have namespaces
if (Utils.isEmpty(namespaceMappings)) {
- return status;
+ return MultiValidationStatus.OK_STATUS;
}
+ final MultiValidationStatus status = new MultiValidationStatus();
final List<String> prefixes = new
ArrayList<String>(namespaceMappings.size());
final List<String> uris = new
ArrayList<String>(namespaceMappings.size());
@@ -429,7 +488,7 @@
* @return the status (never <code>null</code>)
*/
public static ValidationStatus validateNodeTypeDefinition( final NodeTypeDefinition
nodeTypeDefinition ) {
- Utils.isNotNull(nodeTypeDefinition, "nodeTypeDefinition");
//$NON-NLS-1$
+ Utils.verifyIsNotNull(nodeTypeDefinition, "nodeTypeDefinition");
//$NON-NLS-1$
/**
* <pre>
@@ -465,28 +524,8 @@
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.emptySuperTypes,
nodeTypeDefinitionName)));
}
} else {
- final List<String> names = new
ArrayList<String>(superTypeNames.length);
-
- for (final String superTypeName : superTypeNames) {
- // ERROR - Invalid super type name
- validateLocalName(superTypeName, Messages.superTypeName, status);
-
- if (!Utils.isEmpty(superTypeName)) {
- // ERROR - Duplicate super type name
- if (names.contains(superTypeName)) {
-
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateSuperType,
-
nodeTypeDefinitionName, superTypeName)));
- } else {
- names.add(superTypeName);
- }
- }
- }
-
- // ERROR - Cannot have explicit super types when super types is marked as
a variant
- if
(nodeTypeDefinition.getState(NodeTypeDefinition.PropertyName.SUPERTYPES) != Value.IS) {
-
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.superTypesExistButMarkedAsVariant,
-
nodeTypeDefinitionName)));
- }
+ validateSuperTypes(nodeTypeDefinitionName,
nodeTypeDefinition.getState(NodeTypeDefinition.PropertyName.SUPERTYPES),
+ superTypeNames, status);
}
}
@@ -512,24 +551,7 @@
if (Utils.isEmpty(propertyDefinitions)) {
noPropertyDefinitions = true;
} else {
- final List<String> propNames = new
ArrayList<String>(propertyDefinitions.size());
-
- for (final PropertyDefinition propertyDefn : propertyDefinitions) {
- validatePropertyDefinition(propertyDefn, status);
-
- { // ERROR - Duplicate property definition names
- final String propName = propertyDefn.getName();
-
- if (!Utils.isEmpty(propName)) {
- if (propNames.contains(propName)) {
-
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicatePropertyDefinitionName,
-
nodeTypeDefinitionName, propName)));
- } else {
- propNames.add(propName);
- }
- }
- }
- }
+ validatePropertyDefinitions(nodeTypeDefinitionName, propertyDefinitions,
status);
}
}
@@ -539,24 +561,7 @@
if (Utils.isEmpty(childNodeDefinitions)) {
noChildNodeDefinitions = true;
} else {
- final List<String> childNodeNames = new
ArrayList<String>(childNodeDefinitions.size());
-
- for (final ChildNodeDefinition childNodeDefn : childNodeDefinitions) {
- validateChildNodeDefinition(childNodeDefn, status);
-
- { // ERROR - Duplicate child node definition names
- final String childNodeName = childNodeDefn.getName();
-
- if (!Utils.isEmpty(childNodeName)) {
- if (childNodeNames.contains(childNodeName)) {
-
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateChildNodeDefinitionName,
-
nodeTypeDefinitionName, childNodeName)));
- } else {
- childNodeNames.add(childNodeName);
- }
- }
- }
- }
+ validateChildNodeDefinitions(nodeTypeDefinitionName,
childNodeDefinitions, status);
}
}
@@ -585,20 +590,19 @@
* @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 ) {
+ public static MultiValidationStatus validateNodeTypeDefinitions( final
List<NodeTypeDefinition> nodeTypeDefinitions ) {
/**
* <pre>
* ERROR - Duplicate node type definition names
* </pre>
*/
- final MultiValidationStatus status = new MultiValidationStatus();
-
// OK not to have node type definitions
if (Utils.isEmpty(nodeTypeDefinitions)) {
- return status;
+ return MultiValidationStatus.OK_STATUS;
}
+ final MultiValidationStatus status = new MultiValidationStatus();
final List<String> names = new
ArrayList<String>(nodeTypeDefinitions.size());
for (final NodeTypeDefinition nodeTypeDefinition : nodeTypeDefinitions) {
@@ -638,7 +642,7 @@
* @return the status (never <code>null</code>)
*/
public static ValidationStatus validatePropertyDefinition( final PropertyDefinition
propertyDefinition ) {
- Utils.isNotNull(propertyDefinition, "propertyDefinition");
//$NON-NLS-1$
+ Utils.verifyIsNotNull(propertyDefinition, "propertyDefinition");
//$NON-NLS-1$
/**
* <pre>
@@ -797,6 +801,121 @@
}
/**
+ * @param nodeTypeName the node type name whose property definitions are being
checked (cannot be <code>null</code> or empty)
+ * @param propertyDefinitions the collection of a node type definition's property
definitions to validate (can be
+ * <code>null</code> or empty)
+ * @return the status (never <code>null</code>)
+ */
+ public static MultiValidationStatus validatePropertyDefinitions( final String
nodeTypeName,
+ final
List<PropertyDefinition> propertyDefinitions ) {
+ Utils.verifyIsNotEmpty(nodeTypeName, "nodeTypeName"); //$NON-NLS-1$
+
+ /**
+ * <pre>
+ * ERROR - Duplicate property definition names
+ * </pre>
+ */
+
+ // OK to have none
+ if (Utils.isEmpty(propertyDefinitions)) {
+ return MultiValidationStatus.OK_STATUS;
+ }
+
+ final MultiValidationStatus status = new MultiValidationStatus();
+ final List<String> propNames = new
ArrayList<String>(propertyDefinitions.size());
+
+ for (final PropertyDefinition propertyDefn : propertyDefinitions) {
+ validatePropertyDefinition(propertyDefn, status);
+
+ { // ERROR - Duplicate property definition names
+ final String propName = propertyDefn.getName();
+
+ if (!Utils.isEmpty(propName)) {
+ if (propNames.contains(propName)) {
+
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicatePropertyDefinitionName,
+
nodeTypeName, propName)));
+ } else {
+ propNames.add(propName);
+ }
+ }
+ }
+ }
+
+ return status;
+ }
+
+ /**
+ * @param nodeTypeName the node type name whose property definitions are being
checked (cannot be <code>null</code> or empty)
+ * @param propertyDefinitions the collection of a node type definition's property
definitions 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 validatePropertyDefinitions( final String nodeTypeName,
+ final List<PropertyDefinition>
propertyDefinitions,
+ final MultiValidationStatus status )
{
+ final MultiValidationStatus newStatus = validatePropertyDefinitions(nodeTypeName,
propertyDefinitions);
+
+ if (!newStatus.isOk()) {
+ status.add(newStatus);
+ }
+ }
+
+ /**
+ * @param qname the qualified name being validated (cannot be
<code>null</code>)
+ * @param propertyName the name to use to identify the qualified name (cannot be
<code>null</code> empty)
+ * @return the status (never <code>null</code>)
+ */
+ public static MultiValidationStatus validateQualifiedName( final QualifiedName
qname,
+ String propertyName ) {
+ Utils.verifyIsNotNull(qname, "qname"); //$NON-NLS-1$
+
+ final MultiValidationStatus status = new MultiValidationStatus();
+
+ { // qualifier part
+ final String qualifier = qname.getQualifier();
+
+ if (!Utils.isEmpty(qualifier)) {
+ final ValidationStatus qualifierStatus = validateLocalName(qualifier,
propertyName);
+
+ if (!qualifierStatus.isOk()) {
+ status.add(qualifierStatus);
+ }
+ }
+ }
+
+ { // unqualified name part
+ final String unqualifiedName = qname.getUnqualifiedName();
+
+ if (Utils.isEmpty(unqualifiedName)) {
+
status.add(ValidationStatus.createErrorMessage(Messages.emptyUnqualifiedName));
+ } else {
+ final ValidationStatus nameStatus = validateLocalName(unqualifiedName,
propertyName);
+
+ if (!nameStatus.isOk()) {
+ status.add(nameStatus);
+ }
+ }
+ }
+
+ return status;
+ }
+
+ /**
+ * @param qname the qualified name being validated (cannot be
<code>null</code>)
+ * @param propertyName the name to use to identify the qualified name (cannot be
<code>null</code> empty)
+ * @param status the status to add the new status to (never
<code>null</code>)
+ */
+ public static void validateQualifiedName( final QualifiedName qname,
+ String propertyName,
+ final MultiValidationStatus status ) {
+ final MultiValidationStatus newStatus = validateQualifiedName(qname,
propertyName);
+
+ 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>)
*/
@@ -826,6 +945,75 @@
}
/**
+ * @param nodeTypeDefinitionName the node type name whose supertypes are being
checked (cannot be <code>null</code> or empty)
+ * @param superTypesState the supertypes property state (cannot be
<code>null</code>)
+ * @param superTypeNames the collection of a node type definition's supertypes to
validate (can be <code>null</code> or empty)
+ * @return the status (never <code>null</code>)
+ */
+ public static MultiValidationStatus validateSuperTypes( final String
nodeTypeDefinitionName,
+ final Value superTypesState,
+ final String[] superTypeNames
) {
+ Utils.verifyIsNotEmpty(nodeTypeDefinitionName,
"nodeTypeDefinitionName"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(superTypesState, "superTypesState");
//$NON-NLS-1$
+
+ /**
+ * <pre>
+ * ERROR - Invalid super type name
+ * ERROR - Duplicate super type name
+ * ERROR - Cannot have explicit super types when super types is marked as a
variant
+ * </pre>
+ */
+
+ // OK to have none
+ if (Utils.isEmpty(superTypeNames)) {
+ return MultiValidationStatus.OK_STATUS;
+ }
+
+ final MultiValidationStatus status = new MultiValidationStatus();
+ final List<String> names = new
ArrayList<String>(superTypeNames.length);
+
+ for (final String superTypeName : superTypeNames) {
+ // ERROR - Invalid super type name
+ validateLocalName(superTypeName, Messages.superTypeName, status);
+
+ if (!Utils.isEmpty(superTypeName)) {
+ // ERROR - Duplicate super type name
+ if (names.contains(superTypeName)) {
+
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateSuperType,
nodeTypeDefinitionName,
+
superTypeName)));
+ } else {
+ names.add(superTypeName);
+ }
+ }
+ }
+
+ // ERROR - Cannot have explicit super types when super types is marked as a
variant
+ if (superTypesState != Value.IS) {
+
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.superTypesExistButMarkedAsVariant,
+
nodeTypeDefinitionName)));
+ }
+
+ return status;
+ }
+
+ /**
+ * @param nodeTypeDefinitionName the node type name whose supertypes are being
checked (cannot be <code>null</code> or empty)
+ * @param superTypesState the supertypes property state (cannot be
<code>null</code>)
+ * @param superTypeNames the collection of a node type definition's supertypes 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 validateSuperTypes( final String nodeTypeDefinitionName,
+ final Value superTypesState,
+ final String[] superTypeNames,
+ final MultiValidationStatus status ) {
+ final MultiValidationStatus newStatus =
validateSuperTypes(nodeTypeDefinitionName, superTypesState, superTypeNames);
+
+ if (!newStatus.isOk()) {
+ status.add(newStatus);
+ }
+ }
+
+ /**
* @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>)
@@ -854,8 +1042,8 @@
public static ValidationStatus validateValueConstraint( final String constraint ) {
Utils.verifyIsNotEmpty(constraint, "constraint"); //$NON-NLS-1$
- // TODO implement
- return null;
+ // TODO implement validateValueConstraint
+ return ValidationStatus.OK_STATUS;
}
/**
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java 2012-03-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -23,22 +23,6 @@
public class CompactNodeTypeDefinition implements CndElement {
/**
- * The property names whose <code>toString()</code> is used in {@link
PropertyChangeEvent}s.
- */
- public enum PropertyName {
-
- /**
- * The namespace mappings property.
- */
- NAMESPACE_MAPPINGS,
-
- /**
- * The node type definitions property.
- */
- NODE_TYPE_DEFINITIONS
- }
-
- /**
* The registered property change listeners (never <code>null</code>).
*/
private final CopyOnWriteArrayList<PropertyChangeListener> listeners;
@@ -64,8 +48,8 @@
* @param newListener the listener being registered (cannot be
<code>null</code>)
* @return <code>true</code> if registered
*/
- public boolean addListener( PropertyChangeListener newListener ) {
- Utils.isNotNull(newListener, "newListener"); //$NON-NLS-1$
+ public boolean addListener( final PropertyChangeListener newListener ) {
+ Utils.verifyIsNotNull(newListener, "newListener"); //$NON-NLS-1$
return this.listeners.addIfAbsent(newListener);
}
@@ -76,8 +60,8 @@
* @param namespaceMappingToAdd the namespace mapping being added (cannot be
<code>null</code>)
* @return <code>true</code> if added
*/
- public boolean addNamespaceMapping( NamespaceMapping namespaceMappingToAdd ) {
- Utils.isNotNull(namespaceMappingToAdd, "namespaceMappingToAdd");
//$NON-NLS-1$
+ public boolean addNamespaceMapping( final NamespaceMapping namespaceMappingToAdd ) {
+ Utils.verifyIsNotNull(namespaceMappingToAdd, "namespaceMappingToAdd");
//$NON-NLS-1$
if (this.namespaceMappings == null) {
this.namespaceMappings = new ArrayList<NamespaceMapping>();
@@ -98,8 +82,8 @@
* @param nodeTypeDefinitionToAdd the node type definition being added (cannot be
<code>null</code>)
* @return <code>true</code> if added
*/
- public boolean addNodeTypeDefinition( NodeTypeDefinition nodeTypeDefinitionToAdd ) {
- Utils.isNotNull(nodeTypeDefinitionToAdd, "nodeTypeDefinitionToAdd");
//$NON-NLS-1$
+ public boolean addNodeTypeDefinition( final NodeTypeDefinition
nodeTypeDefinitionToAdd ) {
+ Utils.verifyIsNotNull(nodeTypeDefinitionToAdd,
"nodeTypeDefinitionToAdd"); //$NON-NLS-1$
if (this.nodeTypeDefinitions == null) {
this.nodeTypeDefinitions = new ArrayList<NodeTypeDefinition>();
@@ -127,7 +111,7 @@
boolean wasCleared = false;
if (!this.namespaceMappings.isEmpty()) {
- Object oldValue = new
ArrayList<NamespaceMapping>(this.namespaceMappings);
+ final Object oldValue = new
ArrayList<NamespaceMapping>(this.namespaceMappings);
wasCleared = true;
this.namespaceMappings.clear();
notifyChangeListeners(PropertyName.NAMESPACE_MAPPINGS, oldValue, null);
@@ -151,7 +135,7 @@
boolean wasCleared = false;
if (!this.nodeTypeDefinitions.isEmpty()) {
- Object oldValue = new
ArrayList<NodeTypeDefinition>(nodeTypeDefinitions);
+ final Object oldValue = new
ArrayList<NodeTypeDefinition>(this.nodeTypeDefinitions);
wasCleared = true;
this.nodeTypeDefinitions.clear();
notifyChangeListeners(PropertyName.NODE_TYPE_DEFINITIONS, oldValue, null);
@@ -209,12 +193,12 @@
final Object newValue ) {
assert (property != null) : "property is null"; //$NON-NLS-1$
- 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);
}
@@ -225,8 +209,8 @@
* @param listener the listener being unregistered (cannot be
<code>null</code>)
* @return <code>true</code> if removed
*/
- public boolean removeListener( PropertyChangeListener listener ) {
- Utils.isNotNull(listener, "listener"); //$NON-NLS-1$
+ public boolean removeListener( final PropertyChangeListener listener ) {
+ Utils.verifyIsNotNull(listener, "listener"); //$NON-NLS-1$
return this.listeners.remove(listener);
}
@@ -237,8 +221,8 @@
* @param namespaceMappingToRemove the namespace mapping being removed (cannot be
<code>null</code>)
* @return <code>true</code> if removed
*/
- public boolean removeNamespaceMapping( NamespaceMapping namespaceMappingToRemove ) {
- Utils.isNotNull(namespaceMappingToRemove, "namespaceMappingToRemove");
//$NON-NLS-1$
+ public boolean removeNamespaceMapping( final NamespaceMapping
namespaceMappingToRemove ) {
+ Utils.verifyIsNotNull(namespaceMappingToRemove,
"namespaceMappingToRemove"); //$NON-NLS-1$
if ((this.namespaceMappings != null) &&
this.namespaceMappings.remove(namespaceMappingToRemove)) {
notifyChangeListeners(PropertyName.NAMESPACE_MAPPINGS,
namespaceMappingToRemove, null);
@@ -260,8 +244,8 @@
* @param nodeTypeDefinitionToRemove the node type definition being removed (cannot
be <code>null</code>)
* @return <code>true</code> if removed
*/
- public boolean removeNodeTypeDefinition( NodeTypeDefinition
nodeTypeDefinitionToRemove ) {
- Utils.isNotNull(nodeTypeDefinitionToRemove,
"nodeTypeDefinitionToRemove"); //$NON-NLS-1$
+ public boolean removeNodeTypeDefinition( final NodeTypeDefinition
nodeTypeDefinitionToRemove ) {
+ Utils.verifyIsNotNull(nodeTypeDefinitionToRemove,
"nodeTypeDefinitionToRemove"); //$NON-NLS-1$
if ((this.nodeTypeDefinitions != null) &&
this.nodeTypeDefinitions.remove(nodeTypeDefinitionToRemove)) {
notifyChangeListeners(PropertyName.NODE_TYPE_DEFINITIONS,
nodeTypeDefinitionToRemove, null);
@@ -282,16 +266,18 @@
* @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();
boolean addDelim = false;
{ // namespace mappings
if (!Utils.isEmpty(this.namespaceMappings)) {
final String DELIM = getNamespaceMappingDelimiter();
- for (NamespaceMapping namespaceMapping : this.namespaceMappings) {
- addDelim = Utils.build(builder, addDelim, DELIM,
namespaceMapping.toCndNotation(notationType));
+ for (final NamespaceMapping namespaceMapping : this.namespaceMappings) {
+ if (Utils.build(builder, addDelim, DELIM,
namespaceMapping.toCndNotation(notationType))) {
+ addDelim = true;
+ }
}
builder.append(getEndNamespaceMappingSectionDelimiter());
@@ -302,8 +288,10 @@
if (!Utils.isEmpty(this.nodeTypeDefinitions)) {
final String DELIM = getNodeTypeDefinitionDelimiter();
- for (NodeTypeDefinition nodeTypeDefinition : this.nodeTypeDefinitions) {
- addDelim = Utils.build(builder, addDelim, DELIM,
nodeTypeDefinition.toCndNotation(notationType));
+ for (final NodeTypeDefinition nodeTypeDefinition :
this.nodeTypeDefinitions) {
+ if (Utils.build(builder, addDelim, DELIM,
nodeTypeDefinition.toCndNotation(notationType))) {
+ addDelim = true;
+ }
}
builder.append(getEndNodeTypeDefinitionSectionDelimiter());
@@ -313,4 +301,20 @@
return builder.toString();
}
+ /**
+ * The property names whose <code>toString()</code> is used in {@link
PropertyChangeEvent}s.
+ */
+ public enum PropertyName {
+
+ /**
+ * The namespace mappings property.
+ */
+ NAMESPACE_MAPPINGS,
+
+ /**
+ * The node type definitions property.
+ */
+ NODE_TYPE_DEFINITIONS
+ }
+
}
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/LocalName.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -12,7 +12,7 @@
/**
*
*/
-public class LocalName implements CndElement {
+public class LocalName implements CndElement, Comparable<LocalName> {
private Mode mode = Mode.UNQOUTED;
@@ -35,6 +35,29 @@
/**
* {@inheritDoc}
*
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo( final LocalName that ) {
+ if (equals(that) || Utils.equivalent(get(), that.get())) {
+ return 0;
+ }
+
+ // both can't be empty
+ if (Utils.isEmpty(this.value)) {
+ return -1;
+ }
+
+ if (Utils.isEmpty(that.value)) {
+ return 1;
+ }
+
+ return this.value.compareTo(that.value);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
@@ -108,10 +131,10 @@
/**
* @param newMode the new mode (cannot be <code>null</code>)
- * @return <code>true</code> if the model was changed
+ * @return <code>true</code> if the mode was changed
*/
public boolean setMode( final Mode newMode ) {
- Utils.isNotNull(newMode, "newMode"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(newMode, "newMode"); //$NON-NLS-1$
if (this.mode != newMode) {
this.mode = newMode;
@@ -131,7 +154,7 @@
final StringBuilder builder = new StringBuilder();
Mode notationMode = this.mode;
- if (!Utils.isEmpty(this.value) && this.value.contains(" ")
&& (this.mode == Mode.UNQOUTED)) { //$NON-NLS-1$
+ if (!Utils.isEmpty(this.value) && this.value.contains(Utils.SPACE_STRING)
&& (this.mode == Mode.UNQOUTED)) {
notationMode = Mode.SINGLE_QUOTED;
}
@@ -143,14 +166,28 @@
}
/**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ if (Utils.isEmpty(this.value)) {
+ return Utils.EMPTY_STRING;
+ }
+
+ return this.value;
+ }
+
+ /**
* The quotation preference when using the name in CND notation.
*/
public enum Mode {
/**
- * The name is not surrounded by quotes in the CND notation.
+ * The name is surrounded by double quotes in the CND notation.
*/
- UNQOUTED(Utils.EMPTY_STRING),
+ DOUBLE_QUOTED("\""), //$NON-NLS-1$
/**
* The name is surrounded by single quotes in the CND notation.
@@ -158,9 +195,9 @@
SINGLE_QUOTED("'"), //$NON-NLS-1$
/**
- * The name is surrounded by double quotes in the CND notation.
+ * The name is not surrounded by quotes in the CND notation.
*/
- DOUBLE_QUOTED("\""); //$NON-NLS-1$
+ UNQOUTED(Utils.EMPTY_STRING);
private final String delim;
@@ -178,5 +215,4 @@
return this.delim;
}
}
-
}
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMapping.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMapping.java 2012-03-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMapping.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -16,34 +16,19 @@
/**
* The <code>NamespaceMapping</code> class represents a namespace. Each
namespace mapping includes a prefix and a URI.
*/
-public class NamespaceMapping implements CndElement {
+public class NamespaceMapping implements CndElement, Comparable {
/**
- * The property names whose <code>toString()</code> is used in {@link
PropertyChangeEvent}s.
+ * The delimeter used to separate the prefix from the URI.
*/
- public enum PropertyName {
- /**
- * The namespace prefix.
- */
- PREFIX,
+ public static final String NOTATION_DELIMITER = "="; //$NON-NLS-1$
- /**
- * The namespace URI.
- */
- URI
- }
-
/**
* The prefix used in CND notation before the namespace mapping.
*/
public static final String NOTATION_PREFIX = "<"; //$NON-NLS-1$
/**
- * The delimeter used to separate the prefix from the URI.
- */
- public static final String NOTATION_DELIMITER = "="; //$NON-NLS-1$
-
- /**
* The suffix used in CND notation after the namespace mapping.
*/
public static final String NOTATION_SUFFIX = ">"; //$NON-NLS-1$
@@ -78,8 +63,8 @@
* @param initialPrefix the initial prefix (can be <code>null</code> or
empty)
* @param initialUri the initial URI (can be <code>null</code> or empty)
*/
- public NamespaceMapping( String initialPrefix,
- String initialUri ) {
+ public NamespaceMapping( final String initialPrefix,
+ final String initialUri ) {
this();
this.prefix.set(initialPrefix);
this.uri.set(initialUri);
@@ -89,20 +74,49 @@
* @param newListener the listener being registered (cannot be
<code>null</code>)
* @return <code>true</code> if registered
*/
- public boolean addListener( PropertyChangeListener newListener ) {
- Utils.isNotNull(newListener, "newListener"); //$NON-NLS-1$
+ public boolean addListener( final PropertyChangeListener newListener ) {
+ Utils.verifyIsNotNull(newListener, "newListener"); //$NON-NLS-1$
return this.listeners.addIfAbsent(newListener);
}
/**
* {@inheritDoc}
*
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo( final Object object ) {
+ final NamespaceMapping that = (NamespaceMapping)object;
+ final String thisPrefix = getPrefix();
+ final String thatPrefix = that.getPrefix();
+
+ if (Utils.isEmpty(thisPrefix)) {
+ if (Utils.isEmpty(thatPrefix)) {
+ return 0;
+ }
+
+ // thatName is not empty
+ return 1;
+ }
+
+ // thisName is not empty
+ if (thatPrefix == null) {
+ return 1;
+ }
+
+ // thisName and thatName are not empty
+ return thisPrefix.compareTo(thatPrefix);
+ }
+
+ /**
+ * {@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())) {
- NamespaceMapping that = (NamespaceMapping)obj;
+ final NamespaceMapping that = (NamespaceMapping)obj;
return (this.prefix.equals(that.prefix) &&
this.uri.equals(that.uri));
}
@@ -143,12 +157,12 @@
final Object newValue ) {
assert (property != null) : "property is null"; //$NON-NLS-1$
- 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);
}
@@ -159,8 +173,8 @@
* @param listener the listener being unregistered (cannot be
<code>null</code>)
* @return <code>true</code> if removed
*/
- public boolean removeListener( PropertyChangeListener listener ) {
- Utils.isNotNull(listener, "listener"); //$NON-NLS-1$
+ public boolean removeListener( final PropertyChangeListener listener ) {
+ Utils.verifyIsNotNull(listener, "listener"); //$NON-NLS-1$
return this.listeners.remove(listener);
}
@@ -168,9 +182,9 @@
* @param newPrefix the new prefix value (can be <code>null</code> or
empty)
* @return true if the prefix was changed
*/
- public boolean setPrefix( String newPrefix ) {
- Object oldValue = this.prefix.get();
- boolean changed = this.prefix.set(newPrefix);
+ public boolean setPrefix( final String newPrefix ) {
+ final Object oldValue = this.prefix.get();
+ final boolean changed = this.prefix.set(newPrefix);
if (changed) {
notifyChangeListeners(PropertyName.PREFIX, oldValue, newPrefix);
@@ -183,9 +197,9 @@
* @param newUri then new URI value (can be <code>null</code> or empty)
* @return <code>true</code> if the URI was changed
*/
- public boolean setUri( String newUri ) {
- Object oldValue = this.uri.get();
- boolean changed = this.uri.set(newUri);
+ public boolean setUri( final String newUri ) {
+ final Object oldValue = this.uri.get();
+ final boolean changed = this.uri.set(newUri);
if (changed) {
notifyChangeListeners(PropertyName.URI, oldValue, newUri);
@@ -200,8 +214,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();
builder.append(NOTATION_PREFIX);
builder.append(this.prefix.toCndNotation(notationType));
builder.append(NOTATION_DELIMITER);
@@ -211,4 +225,19 @@
return builder.toString();
}
+ /**
+ * The property names whose <code>toString()</code> is used in {@link
PropertyChangeEvent}s.
+ */
+ public enum PropertyName {
+ /**
+ * The namespace prefix.
+ */
+ PREFIX,
+
+ /**
+ * The namespace URI.
+ */
+ URI
+ }
+
}
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinition.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -31,7 +31,7 @@
/**
* Represents a CND node type definition.
*/
-public class NodeTypeDefinition implements CndElement, NodeTypeTemplate {
+public class NodeTypeDefinition implements CndElement, Comparable, NodeTypeTemplate {
/**
* Then node type name prefix used in the CND notation.
@@ -61,7 +61,7 @@
/**
* The node type name (never <code>null</code> but can have a
<code>null</code> or empty value).
*/
- private final LocalName name;
+ private final QualifiedName name;
/**
* The collection of property definitions (can be <code>null</code>).
@@ -78,7 +78,7 @@
*/
public NodeTypeDefinition() {
this.attributes = new NodeTypeAttributes();
- this.name = new LocalName();
+ this.name = new QualifiedName();
this.superTypes = new SuperTypes();
this.listeners = new CopyOnWriteArrayList<PropertyChangeListener>();
}
@@ -90,7 +90,7 @@
* @return <code>true</code> if successfully added
*/
public boolean addChildNodeDefinition( final ChildNodeDefinition
childNodeDefinitionBeingAdded ) {
- Utils.isNotNull(childNodeDefinitionBeingAdded,
"childNodeDefinitionBeingAdded"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(childNodeDefinitionBeingAdded,
"childNodeDefinitionBeingAdded"); //$NON-NLS-1$
if (this.childNodesDefinitions == null) {
this.childNodesDefinitions = new ArrayList<ChildNodeDefinition>();
@@ -109,7 +109,7 @@
* @return <code>true</code> if successfully added
*/
public boolean addListener( final PropertyChangeListener newListener ) {
- Utils.isNotNull(newListener, "newListener"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(newListener, "newListener"); //$NON-NLS-1$
return this.listeners.addIfAbsent(newListener);
}
@@ -120,7 +120,7 @@
* @return <code>true</code> if successfully added
*/
public boolean addPropertyDefinition( final PropertyDefinition
properyDefinitionBeingAdded ) {
- Utils.isNotNull(properyDefinitionBeingAdded,
"properyDefinitionBeingAdded"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(properyDefinitionBeingAdded,
"properyDefinitionBeingAdded"); //$NON-NLS-1$
if (this.propertyDefinitions == null) {
this.propertyDefinitions = new ArrayList<PropertyDefinition>();
@@ -161,8 +161,8 @@
*/
public boolean changeState( final PropertyName propertyName,
final Value newState ) {
- Utils.isNotNull(propertyName, "propertyName"); //$NON-NLS-1$
- Utils.isNotNull(newState, "newState"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(propertyName, "propertyName"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(newState, "newState"); //$NON-NLS-1$
Object oldValue = null;
final Object newValue = newState;
@@ -254,6 +254,35 @@
return false;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo( final Object object ) {
+ final NodeTypeDefinition that = (NodeTypeDefinition)object;
+ final String thisName = getName();
+ final String thatName = that.getName();
+
+ if (Utils.isEmpty(thisName)) {
+ if (Utils.isEmpty(thatName)) {
+ return 0;
+ }
+
+ // thatName is not empty
+ return 1;
+ }
+
+ // thisName is not empty
+ if (thatName == null) {
+ return 1;
+ }
+
+ // thisName and thatName are not empty
+ return thisName.compareTo(thatName);
+ }
+
private String getChildNodeDefinitionDelimiter() {
return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.CHILD_NODE_DEFINITION_DELIMITER);
}
@@ -302,7 +331,7 @@
}
private String getEndAttributesDelimiter() {
- return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER);
+ return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER);
}
private String getEndChildNodeDefinitionsDelimiter() {
@@ -373,6 +402,10 @@
return this.propertyDefinitions;
}
+ private String getPropertyDefinitionStartDelimiter() {
+ return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.PROPERTY_DEFINITION_START_DELIMITER);
+ }
+
/**
* {@inheritDoc}
*
@@ -383,6 +416,10 @@
return new
ArrayList<PropertyDefinitionTemplate>(getPropertyDefinitions());
}
+ private String getStartChildNodeDefinitionDelimiter() {
+ return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.CHILD_NODE_DEFINITION_START_DELIMITER);
+ }
+
/**
* Can be used to find the attribute state of the abstract, mixin, orderable, primary
item, queryable, and super types
* properties.
@@ -392,7 +429,7 @@
* @throws IllegalArgumentException if a property that does not have an attribute
state is specified
*/
public Value getState( final PropertyName propertyName ) {
- Utils.isNotNull(propertyName, "propertyName"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(propertyName, "propertyName"); //$NON-NLS-1$
if (PropertyName.ABSTRACT == propertyName) {
return this.attributes.getAbstract().get();
@@ -466,7 +503,7 @@
* @return <code>true</code> if property is a variant
*/
public boolean isVariant( final PropertyName propertyName ) {
- Utils.isNotNull(propertyName, "propertyName"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(propertyName, "propertyName"); //$NON-NLS-1$
return (getState(propertyName) == Value.VARIANT);
}
@@ -497,7 +534,7 @@
* @return <code>true</code> if successfully removed
*/
public boolean removeChildNodeDefinition( final ChildNodeDefinition
childNodeDefinitionBeingRemoved ) {
- Utils.isNotNull(childNodeDefinitionBeingRemoved,
"childNodeDefinitionBeingRemoved"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(childNodeDefinitionBeingRemoved,
"childNodeDefinitionBeingRemoved"); //$NON-NLS-1$
if (this.childNodesDefinitions == null) {
return false;
@@ -521,7 +558,7 @@
* @return <code>true</code> if successfully removed
*/
public boolean removeListener( final PropertyChangeListener listener ) {
- Utils.isNotNull(listener, "listener"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(listener, "listener"); //$NON-NLS-1$
return this.listeners.remove(listener);
}
@@ -532,7 +569,7 @@
* @return <code>true</code> if successfully removed
*/
public boolean removePropertyDefinition( final PropertyDefinition
propertyDefinitionBeingRemoved ) {
- Utils.isNotNull(propertyDefinitionBeingRemoved,
"propertyDefinitionBeingRemoved"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(propertyDefinitionBeingRemoved,
"propertyDefinitionBeingRemoved"); //$NON-NLS-1$
if (this.propertyDefinitions == null) {
return false;
@@ -668,7 +705,7 @@
*/
@Override
public String toCndNotation( final NotationType notationType ) {
- final StringBuilder builder = new StringBuilder("- "); //$NON-NLS-1$
+ final StringBuilder builder = new StringBuilder();
{ // name
builder.append(NAME_NOTATION_PREFIX)
@@ -689,16 +726,18 @@
final String notation = this.attributes.toCndNotation(notationType);
if (!Utils.isEmpty(notation)) {
- builder.append(notation).append(getEndAttributesDelimiter());
+ builder.append(notation);
}
+
+ builder.append(getEndAttributesDelimiter());
}
{ // property definitions
if (!Utils.isEmpty(this.propertyDefinitions)) {
- final String PD_DELIM = getPropertyDefinitionDelimiter();
-
for (final PropertyDefinition propDefn : this.propertyDefinitions) {
-
builder.append(propDefn.toCndNotation(notationType)).append(PD_DELIM);
+ builder.append(getPropertyDefinitionStartDelimiter());
+ builder.append(propDefn.toCndNotation(notationType));
+ builder.append(getPropertyDefinitionDelimiter());
}
builder.append(getEndPropertyDefinitionsDelimiter());
@@ -707,10 +746,10 @@
{ // child node definitions
if (!Utils.isEmpty(this.childNodesDefinitions)) {
- final String CND_DELIM = getChildNodeDefinitionDelimiter();
-
for (final ChildNodeDefinition childNodeDefn :
this.childNodesDefinitions) {
-
builder.append(childNodeDefn.toCndNotation(notationType)).append(CND_DELIM);
+ builder.append(getStartChildNodeDefinitionDelimiter());
+ builder.append(childNodeDefn.toCndNotation(notationType));
+ builder.append(getChildNodeDefinitionDelimiter());
}
builder.append(getEndChildNodeDefinitionsDelimiter());
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinition.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinition.java 2012-03-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinition.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -33,93 +33,27 @@
/**
* The <code>PropertyDefinition</code> class represents node type property
definition.
*/
-public class PropertyDefinition implements CndElement, PropertyDefinitionTemplate {
+public class PropertyDefinition implements CndElement, Comparable,
PropertyDefinitionTemplate {
/**
- * The property names whose <code>toString()</code> is used in {@link
PropertyChangeEvent}s.
+ * The prefix used in CND notation before the property definition.
*/
- public enum PropertyName {
+ public static final String NOTATION_PREFIX = "-"; //$NON-NLS-1$
- /**
- * The autocreated attribute.
- */
- AUTOCREATED,
-
- /**
- * A collection of default values.
- */
- DEFAULT_VALUES,
-
- /**
- * The mandatory attribute.
- */
- MANDATORY,
-
- /**
- * The multiple attribute.
- */
- MULTIPLE,
-
- /**
- * The property name.
- */
- NAME,
-
- /**
- * The does not support full text search attribute.
- */
- NO_FULL_TEXT,
-
- /**
- * The does not support query order attribute.
- */
- NO_QUERY_ORDER,
-
- /**
- * The on parent version value.
- */
- ON_PARENT_VERSION,
-
- /**
- * The protected attribute.
- */
- PROTECTED,
-
- /**
- * The collection of supported query operators.
- */
- QUERY_OPS,
-
- /**
- * The property type.
- */
- TYPE,
-
- /**
- * The collection of property constraints.
- */
- VALUE_CONSTRAINTS
- }
-
/**
* Name for a residual property definition.
*/
public static final String RESIDUAL_PROPERTY_NAME = "*"; //$NON-NLS-1$
/**
- * The prefix used in CND notation before the property definition.
- */
- public static final String NOTATION_PREFIX = "-"; //$NON-NLS-1$
-
- /**
* The property attributes (never <code>null</code>).
*/
- private PropertyAttributes attributes;
+ private final PropertyAttributes attributes;
/**
* The property default values (never <code>null</code>).
*/
- private DefaultValues defaultValues;
+ private final DefaultValues defaultValues;
/**
* The registered property change listeners (never <code>null</code>).
@@ -129,7 +63,7 @@
/**
* The property identifier (can be <code>null</code> or empty).
*/
- private final LocalName name;
+ private final QualifiedName name;
/**
* The property type (never <code>null</code>).
@@ -139,14 +73,14 @@
/**
* The property value constraints (never <code>null</code>).
*/
- private ValueConstraints valueConstraints;
+ private final ValueConstraints valueConstraints;
/**
* Constructs an instance with a default type of {@link PropertyType#STRING}.
*/
public PropertyDefinition() {
this.type = PropertyType.DEFAULT_VALUE;
- this.name = new LocalName();
+ this.name = new QualifiedName();
this.attributes = new PropertyAttributes();
this.defaultValues = new DefaultValues();
this.valueConstraints = new ValueConstraints();
@@ -160,7 +94,7 @@
* @param defaultValueBeingAdded the default value being added (cannot be
<code>null</code>)
* @return <code>true</code> if added
*/
- public boolean addDefaultValue( String defaultValueBeingAdded ) {
+ public boolean addDefaultValue( final String defaultValueBeingAdded ) {
if (this.defaultValues.add(defaultValueBeingAdded)) {
notifyChangeListeners(PropertyName.DEFAULT_VALUES, null,
defaultValueBeingAdded);
return true; // added
@@ -173,8 +107,8 @@
* @param newListener the listener being registered (cannot be
<code>null</code>)
* @return <code>true</code> if registered
*/
- public boolean addListener( PropertyChangeListener newListener ) {
- Utils.isNotNull(newListener, "newListener"); //$NON-NLS-1$
+ public boolean addListener( final PropertyChangeListener newListener ) {
+ Utils.verifyIsNotNull(newListener, "newListener"); //$NON-NLS-1$
return this.listeners.addIfAbsent(newListener);
}
@@ -182,7 +116,7 @@
* @param operator the query operator being added (cannot be
<code>null</code>)
* @return <code>true</code> if added
*/
- public boolean addQueryOperator( QueryOperator operator ) {
+ public boolean addQueryOperator( final QueryOperator operator ) {
if (this.attributes.getQueryOps().add(operator)) {
notifyChangeListeners(PropertyName.QUERY_OPS, null, operator);
return true; // added
@@ -198,7 +132,7 @@
* @param valueConstraintBeingAdded the value constraint being added (cannot be
<code>null</code>)
* @return <code>true</code> if added
*/
- public boolean addValueConstraint( String valueConstraintBeingAdded ) {
+ public boolean addValueConstraint( final String valueConstraintBeingAdded ) {
if (this.valueConstraints.add(valueConstraintBeingAdded)) {
notifyChangeListeners(PropertyName.VALUE_CONSTRAINTS, null,
valueConstraintBeingAdded);
return true; // added
@@ -216,10 +150,10 @@
* @param newState the new attribute state (cannot be <code>null</code>)
* @return <code>true</code> if the attribute state was changed
*/
- public boolean changeState( PropertyName propertyName,
- AttributeState.Value newState ) {
- Utils.isNotNull(propertyName, "propertyName"); //$NON-NLS-1$
- Utils.isNotNull(newState, "newState"); //$NON-NLS-1$
+ public boolean changeState( final PropertyName propertyName,
+ final AttributeState.Value newState ) {
+ Utils.verifyIsNotNull(propertyName, "propertyName"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(newState, "newState"); //$NON-NLS-1$
Object oldValue = null;
Object newValue = newState;
@@ -279,7 +213,7 @@
* @return <code>true</code> if at least one default value was removed
*/
public boolean clearDefaultValues() {
- List<String> oldValue = new
ArrayList<String>(this.defaultValues.getSupportedItems());
+ final List<String> oldValue = new
ArrayList<String>(this.defaultValues.getSupportedItems());
if (this.defaultValues.clear()) {
notifyChangeListeners(PropertyName.DEFAULT_VALUES, oldValue, null);
@@ -296,7 +230,7 @@
* @return <code>true</code> if at least one value constraint was
removed
*/
public boolean clearValueConstraints() {
- List<String> oldValue = new
ArrayList<String>(valueConstraints.getSupportedItems());
+ final List<String> oldValue = new
ArrayList<String>(this.valueConstraints.getSupportedItems());
if (this.valueConstraints.clear()) {
notifyChangeListeners(PropertyName.VALUE_CONSTRAINTS, oldValue, null);
@@ -309,6 +243,49 @@
/**
* {@inheritDoc}
*
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo( final Object object ) {
+ final PropertyDefinition that = (PropertyDefinition)object;
+ final String thisName = getName();
+ final String thatName = that.getName();
+
+ if (Utils.isEmpty(thisName)) {
+ if (Utils.isEmpty(thatName)) {
+ return 0;
+ }
+
+ // thatName is not empty
+ return 1;
+ }
+
+ // thisName is not empty
+ if (thatName == null) {
+ return 1;
+ }
+
+ // thisName and thatName are not empty
+ return thisName.compareTo(thatName);
+ }
+
+ /**
+ * @param notationType the notation type being requested (cannot be
<code>null</code>)
+ * @return the CND notation (never <code>null</code>)
+ */
+ public String getAttributesCndNotation( final NotationType notationType ) {
+ final String cndNotation = this.attributes.toCndNotation(notationType);
+
+ if (cndNotation == null) {
+ return Utils.EMPTY_STRING;
+ }
+
+ return cndNotation;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see javax.jcr.nodetype.PropertyDefinition#getAvailableQueryOperators()
*/
@Override
@@ -320,21 +297,14 @@
* {@inheritDoc}
*
* @see javax.jcr.nodetype.ItemDefinition#getDeclaringNodeType()
+ * @throws UnsupportedOperationException if method is called
*/
@Override
public NodeType getDeclaringNodeType() {
- // TODO implement
- return null;
+ throw new UnsupportedOperationException();
}
/**
- * @return the default values (never <code>null</code>)
- */
- public List<String> getDefaultValuesAsStrings() {
- return this.defaultValues.getSupportedItems();
- }
-
- /**
* {@inheritDoc}
*
* @see javax.jcr.nodetype.PropertyDefinition#getDefaultValues()
@@ -344,6 +314,13 @@
return this.defaultValues.asJcrValues();
}
+ /**
+ * @return the default values (never <code>null</code>)
+ */
+ public List<String> getDefaultValuesAsStrings() {
+ return this.defaultValues.getSupportedItems();
+ }
+
private String getDelimiter() {
return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER);
}
@@ -373,6 +350,10 @@
return this.attributes.getOnParentVersion().asJcrValue();
}
+ private String getPrefixEndDelimiter() {
+ return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.PROPERTY_DEFINITION_END_PREFIX_DELIMITER);
+ }
+
/**
* {@inheritDoc}
*
@@ -391,8 +372,8 @@
* @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 ) {
- Utils.isNotNull(propertyName, "propertyName"); //$NON-NLS-1$
+ public Value getState( final PropertyName propertyName ) {
+ Utils.verifyIsNotNull(propertyName, "propertyName"); //$NON-NLS-1$
if (PropertyName.AUTOCREATED == propertyName) {
return this.attributes.getAutocreated().get();
@@ -459,6 +440,14 @@
}
/**
+ * @param notationType
+ * @return the CND notation for the value constraints (never
<code>null</code> but can be empty)
+ */
+ public String getValueConstraintsCndNotation( final NotationType notationType ) {
+ return this.valueConstraints.toCndNotation(notationType);
+ }
+
+ /**
* {@inheritDoc}
*
* @see javax.jcr.nodetype.ItemDefinition#isAutoCreated()
@@ -522,8 +511,8 @@
* @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 ) {
- Utils.isNotNull(propertyName, "propertyName"); //$NON-NLS-1$
+ public boolean isVariant( final PropertyName propertyName ) {
+ Utils.verifyIsNotNull(propertyName, "propertyName"); //$NON-NLS-1$
if (PropertyName.ON_PARENT_VERSION == propertyName) {
return (this.attributes.getOnParentVersion() == OnParentVersion.VARIANT);
@@ -544,12 +533,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);
}
@@ -563,7 +552,7 @@
* @param defaultValueBeingRemoved the default value being removed (cannot be
<code>null</code>)
* @return <code>true</code> if removed
*/
- public boolean removeDefaultValue( String defaultValueBeingRemoved ) {
+ public boolean removeDefaultValue( final String defaultValueBeingRemoved ) {
if (this.defaultValues.remove(defaultValueBeingRemoved)) {
notifyChangeListeners(PropertyName.DEFAULT_VALUES, defaultValueBeingRemoved,
null);
return true; // removed
@@ -576,8 +565,8 @@
* @param listener the listener being unregistered (cannot be
<code>null</code>)
* @return <code>true</code> if removed
*/
- public boolean removeListener( PropertyChangeListener listener ) {
- Utils.isNotNull(listener, "listener"); //$NON-NLS-1$
+ public boolean removeListener( final PropertyChangeListener listener ) {
+ Utils.verifyIsNotNull(listener, "listener"); //$NON-NLS-1$
return this.listeners.remove(listener);
}
@@ -585,7 +574,7 @@
* @param operator the query operator being removed (cannot be
<code>null</code>)
* @return <code>true</code> if removed
*/
- public boolean removeQueryOperator( QueryOperator operator ) {
+ public boolean removeQueryOperator( final QueryOperator operator ) {
if (this.attributes.getQueryOps().remove(operator)) {
notifyChangeListeners(PropertyName.QUERY_OPS, operator, null);
return true; // removed
@@ -601,7 +590,7 @@
* @param valueConstraintBeingRemoved the value constraint being removed (cannot be
<code>null</code>)
* @return <code>true</code> if removed
*/
- public boolean removeValueConstraint( String valueConstraintBeingRemoved ) {
+ public boolean removeValueConstraint( final String valueConstraintBeingRemoved ) {
if (this.valueConstraints.remove(valueConstraintBeingRemoved)) {
notifyChangeListeners(PropertyName.VALUE_CONSTRAINTS,
valueConstraintBeingRemoved, null);
return true; // removed
@@ -616,8 +605,8 @@
* @see javax.jcr.nodetype.PropertyDefinitionTemplate#setAutoCreated(boolean)
*/
@Override
- public void setAutoCreated( boolean newAutocreated ) {
- AttributeState.Value newState = (newAutocreated ? AttributeState.Value.IS :
AttributeState.Value.IS_NOT);
+ public void setAutoCreated( final boolean newAutocreated ) {
+ final AttributeState.Value newState = (newAutocreated ? AttributeState.Value.IS :
AttributeState.Value.IS_NOT);
changeState(PropertyName.AUTOCREATED, newState);
}
@@ -627,18 +616,18 @@
* @see
javax.jcr.nodetype.PropertyDefinitionTemplate#setAvailableQueryOperators(java.lang.String[])
*/
@Override
- public void setAvailableQueryOperators( String[] newOperators ) {
- QueryOperators queryOps = this.attributes.getQueryOps();
- List<QueryOperator> oldOperators = queryOps.getSupportedItems();
+ public void setAvailableQueryOperators( final String[] newOperators ) {
+ final QueryOperators queryOps = this.attributes.getQueryOps();
+ final List<QueryOperator> oldOperators = queryOps.getSupportedItems();
boolean changed = queryOps.clear();
if (!Utils.isEmpty(newOperators)) {
- for (String operator : newOperators) {
+ for (final String operator : newOperators) {
try {
if (queryOps.add(operator.trim())) {
changed = true;
}
- } catch (Exception e) {
+ } catch (final Exception e) {
// TODO log the invalid query operator
}
}
@@ -655,17 +644,17 @@
* @see
javax.jcr.nodetype.PropertyDefinitionTemplate#setDefaultValues(javax.jcr.Value[])
*/
@Override
- public void setDefaultValues( javax.jcr.Value[] newDefaultValues ) {
- List<String> items = this.defaultValues.getSupportedItems();
+ public void setDefaultValues( final javax.jcr.Value[] newDefaultValues ) {
+ final List<String> items = this.defaultValues.getSupportedItems();
boolean changed = this.defaultValues.clear();
if (!Utils.isEmpty(newDefaultValues)) {
- for (javax.jcr.Value defaultValue : newDefaultValues) {
+ for (final javax.jcr.Value defaultValue : newDefaultValues) {
try {
if (this.defaultValues.add(defaultValue.getString())) {
changed = true;
}
- } catch (Exception e) {
+ } catch (final Exception e) {
// TODO log this
}
}
@@ -682,8 +671,8 @@
* @see javax.jcr.nodetype.PropertyDefinitionTemplate#setFullTextSearchable(boolean)
*/
@Override
- public void setFullTextSearchable( boolean newFullTextSearchable ) {
- AttributeState.Value newState = (newFullTextSearchable ?
AttributeState.Value.IS_NOT : AttributeState.Value.IS);
+ public void setFullTextSearchable( final boolean newFullTextSearchable ) {
+ final AttributeState.Value newState = (newFullTextSearchable ?
AttributeState.Value.IS_NOT : AttributeState.Value.IS);
changeState(PropertyName.NO_FULL_TEXT, newState);
}
@@ -693,8 +682,8 @@
* @see javax.jcr.nodetype.PropertyDefinitionTemplate#setMandatory(boolean)
*/
@Override
- public void setMandatory( boolean newMandatory ) {
- AttributeState.Value newState = (newMandatory ? AttributeState.Value.IS :
AttributeState.Value.IS_NOT);
+ public void setMandatory( final boolean newMandatory ) {
+ final AttributeState.Value newState = (newMandatory ? AttributeState.Value.IS :
AttributeState.Value.IS_NOT);
changeState(PropertyName.MANDATORY, newState);
}
@@ -704,8 +693,8 @@
* @see javax.jcr.nodetype.PropertyDefinitionTemplate#setMultiple(boolean)
*/
@Override
- public void setMultiple( boolean newMultiple ) {
- AttributeState.Value newState = (newMultiple ? AttributeState.Value.IS :
AttributeState.Value.IS_NOT);
+ public void setMultiple( final boolean newMultiple ) {
+ final AttributeState.Value newState = (newMultiple ? AttributeState.Value.IS :
AttributeState.Value.IS_NOT);
changeState(PropertyName.MULTIPLE, newState);
}
@@ -713,8 +702,8 @@
* @param newName the new node name (can be <code>null</code> or empty)
*/
@Override
- public void setName( String newName ) {
- Object oldValue = this.name.get();
+ public void setName( final String newName ) {
+ final Object oldValue = getName();
if (this.name.set(newName)) {
notifyChangeListeners(PropertyName.NAME, oldValue, newName);
@@ -727,8 +716,8 @@
* @see javax.jcr.nodetype.PropertyDefinitionTemplate#setOnParentVersion(int)
*/
@Override
- public void setOnParentVersion( int newOpv ) {
- OnParentVersion oldValue = this.attributes.getOnParentVersion();
+ public void setOnParentVersion( final int newOpv ) {
+ final OnParentVersion oldValue = this.attributes.getOnParentVersion();
if
(this.attributes.setOnParentVersion(OnParentVersion.findUsingJcrValue(newOpv))) {
notifyChangeListeners(PropertyName.ON_PARENT_VERSION, oldValue, newOpv);
@@ -741,8 +730,8 @@
* @param newOpv the new OPV value (cannot be <code>null</code>)
* @return <code>true</code> if successfully changed
*/
- public boolean setOnParentVersion( String newOpv ) {
- OnParentVersion oldValue = this.attributes.getOnParentVersion();
+ public boolean setOnParentVersion( final String newOpv ) {
+ final OnParentVersion oldValue = this.attributes.getOnParentVersion();
if (this.attributes.setOnParentVersion(OnParentVersion.find(newOpv))) {
notifyChangeListeners(PropertyName.ON_PARENT_VERSION, oldValue, newOpv);
@@ -758,8 +747,8 @@
* @see javax.jcr.nodetype.PropertyDefinitionTemplate#setProtected(boolean)
*/
@Override
- public void setProtected( boolean newProtected ) {
- AttributeState.Value newState = (newProtected ? AttributeState.Value.IS :
AttributeState.Value.IS_NOT);
+ public void setProtected( final boolean newProtected ) {
+ final AttributeState.Value newState = (newProtected ? AttributeState.Value.IS :
AttributeState.Value.IS_NOT);
changeState(PropertyName.PROTECTED, newState);
}
@@ -769,8 +758,8 @@
* @see javax.jcr.nodetype.PropertyDefinitionTemplate#setQueryOrderable(boolean)
*/
@Override
- public void setQueryOrderable( boolean newQueryOrderable ) {
- AttributeState.Value newState = (newQueryOrderable ? AttributeState.Value.IS_NOT
: AttributeState.Value.IS);
+ public void setQueryOrderable( final boolean newQueryOrderable ) {
+ final AttributeState.Value newState = (newQueryOrderable ?
AttributeState.Value.IS_NOT : AttributeState.Value.IS);
changeState(PropertyName.NO_QUERY_ORDER, newState);
}
@@ -780,7 +769,7 @@
* @see javax.jcr.nodetype.PropertyDefinitionTemplate#setRequiredType(int)
*/
@Override
- public void setRequiredType( int newPropertyType ) {
+ public void setRequiredType( final int newPropertyType ) {
setType(PropertyType.findUsingJcrValue(newPropertyType));
}
@@ -790,9 +779,9 @@
* @param newType the proposed new type (cannot be <code>null</code>)
* @return <code>true</code> if the type was changed
*/
- public boolean setType( PropertyType newType ) {
+ public boolean setType( final PropertyType newType ) {
if (this.type != newType) {
- PropertyType oldValue = this.type;
+ final PropertyType oldValue = this.type;
this.type = newType;
notifyChangeListeners(PropertyName.TYPE, oldValue, this.type);
return true; // type changed
@@ -807,12 +796,12 @@
* @see
javax.jcr.nodetype.PropertyDefinitionTemplate#setValueConstraints(java.lang.String[])
*/
@Override
- public void setValueConstraints( String[] newConstraints ) {
- List<String> items = this.valueConstraints.getSupportedItems();
+ public void setValueConstraints( final String[] newConstraints ) {
+ final List<String> items = this.valueConstraints.getSupportedItems();
boolean changed = this.valueConstraints.clear();
if (!Utils.isEmpty(newConstraints)) {
- for (String constraint : newConstraints) {
+ for (final String constraint : newConstraints) {
if (this.valueConstraints.add(constraint)) {
changed = true;
}
@@ -830,43 +819,85 @@
* @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);
+ builder.append(getPrefixEndDelimiter());
+
final String DELIM = getDelimiter();
- { // name
- builder.append(this.name.toCndNotation(notationType));
- }
+ builder.append(this.name.toCndNotation(notationType));
+ Utils.build(builder, true, DELIM, this.type.toCndNotation(notationType));
+ Utils.build(builder, true, DELIM,
this.defaultValues.toCndNotation(notationType));
+ Utils.build(builder, true, DELIM, this.attributes.toCndNotation(notationType));
+ Utils.build(builder, true, DELIM,
this.valueConstraints.toCndNotation(notationType));
- { // type
- builder.append(DELIM).append(getType().toCndNotation(notationType));
- }
+ return builder.toString();
+ }
- { // default values
- String notation = this.defaultValues.toCndNotation(notationType);
+ /**
+ * The property names whose <code>toString()</code> is used in {@link
PropertyChangeEvent}s.
+ */
+ public enum PropertyName {
- if (!Utils.isEmpty(notation)) {
- builder.append(DELIM).append(notation);
- }
- }
+ /**
+ * The autocreated attribute.
+ */
+ AUTOCREATED,
- { // attributes
- String notation = this.attributes.toCndNotation(notationType);
+ /**
+ * A collection of default values.
+ */
+ DEFAULT_VALUES,
- if (!Utils.isEmpty(notation)) {
- builder.append(DELIM).append(notation);
- }
- }
+ /**
+ * The mandatory attribute.
+ */
+ MANDATORY,
- { // value constraints
- String notation = this.valueConstraints.toCndNotation(notationType);
+ /**
+ * The multiple attribute.
+ */
+ MULTIPLE,
- if (!Utils.isEmpty(notation)) {
- builder.append(DELIM).append(notation);
- }
- }
+ /**
+ * The property name.
+ */
+ NAME,
- return builder.toString();
+ /**
+ * The does not support full text search attribute.
+ */
+ NO_FULL_TEXT,
+
+ /**
+ * The does not support query order attribute.
+ */
+ NO_QUERY_ORDER,
+
+ /**
+ * The on parent version value.
+ */
+ ON_PARENT_VERSION,
+
+ /**
+ * The protected attribute.
+ */
+ PROTECTED,
+
+ /**
+ * The collection of supported query operators.
+ */
+ QUERY_OPS,
+
+ /**
+ * The property type.
+ */
+ TYPE,
+
+ /**
+ * The collection of property constraints.
+ */
+ VALUE_CONSTRAINTS
}
}
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/QualifiedName.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/QualifiedName.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/QualifiedName.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -0,0 +1,284 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
+ */
+package org.jboss.tools.modeshape.jcr.cnd;
+
+import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.cnd.LocalName.Mode;
+
+/**
+ * A name that may or may not have a qualifier.
+ */
+public class QualifiedName implements CndElement, Comparable<QualifiedName> {
+
+ /**
+ * The character that separates the qualifier and the local name. Value is {@value}
;
+ */
+ public static final char DELIM = ':';
+
+ /**
+ * A string representation of the {@link #DELIM delimiter character}.
+ */
+ public static final String DELIM_STRING = Character.toString(DELIM);
+
+ /**
+ * @param qualifiedName the qualified name being parsed (can be
<code>null</code> or empty)
+ * @return the qualified name (never <code>null</code>)
+ */
+ public static QualifiedName parse( final String qualifiedName ) {
+ String qualifier = null;
+ String name = null;
+
+ if (!Utils.isEmpty(qualifiedName)) {
+ final int index = qualifiedName.indexOf(DELIM_STRING);
+
+ if ((index == -1) || (qualifiedName.length() == 1)) {
+ name = qualifiedName;
+ } else {
+ qualifier = qualifiedName.substring(0, index);
+
+ if ((index + 1) <= qualifiedName.length()) {
+ name = qualifiedName.substring(index + 1);
+ }
+ }
+ }
+
+ return new QualifiedName(qualifier, name);
+ }
+
+ /**
+ * The quotation mode for the CND notation.
+ */
+ private Mode mode = Mode.UNQOUTED;
+
+ /**
+ * The part of the name that comes after the delimiter (never
<code>null</code>).
+ */
+ private final LocalName name;
+
+ /**
+ * The part of the name that comes before the delimiter (never
<code>null</code>).
+ */
+ private final LocalName qualifier;
+
+ /**
+ * Constructs a qualified name with an empty qualifier and an empty unqualified
name.
+ */
+ public QualifiedName() {
+ this.qualifier = new LocalName();
+ this.name = new LocalName();
+ }
+
+ /**
+ * @param initialQualifier the local name that is the qualifier (can be
<code>null</code> or empty)
+ * @param initialUnqualifiedName the local name without a qualifier (can be
<code>null</code> or empty)
+ */
+ public QualifiedName( final String initialQualifier,
+ final String initialUnqualifiedName ) {
+ this();
+ this.qualifier.set(initialQualifier);
+ this.name.set(initialUnqualifiedName);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo( final QualifiedName that ) {
+ if (equals(that)) {
+ return 0;
+ }
+
+ final int qualifierResult = this.qualifier.compareTo(that.qualifier);
+ final int nameResult = this.name.compareTo(that.name);
+
+ if (qualifierResult < 0) {
+ // less than qualifier and less than name
+ if (nameResult < 0) {
+ return -1000;
+ }
+
+ // less than qualifier and equal to name
+ if (nameResult == 0) {
+ return -100;
+ }
+
+ // less than qualifier and greater than name
+ return -10;
+ }
+
+ if (qualifierResult == 0) {
+ // equal to qualifier and less than name
+ if (nameResult < 0) {
+ return -1;
+ }
+
+ // equal to qualifier and equal to name
+ if (nameResult == 0) {
+ return 0;
+ }
+
+ // equal to qualifier and greater than name
+ return 1;
+ }
+
+ // greater than qualifier and less than name
+ if (nameResult < 0) {
+ return 10;
+ }
+
+ // greater than qualifier and equal to name
+ if (nameResult == 0) {
+ return 100;
+ }
+
+ // greater than qualifier and greater than name
+ return 1000;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( final Object obj ) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || !getClass().equals(obj.getClass())) {
+ return false;
+ }
+
+ final QualifiedName that = (QualifiedName)obj;
+ return (this.qualifier.equals(that.qualifier) &&
this.name.equals(that.name));
+ }
+
+ /**
+ * If there is no qualifier, just the unqualified name is returned (no preceding
delimiter). If there is only a qualifier, the
+ * qualifier and the delimiter is returned. If there is neither a qualifier or an
unqualified name, an empty string is returned.
+ *
+ * @return the unqualified name (never <code>null</code> but can be
empty)
+ */
+ public String get() {
+ final StringBuilder builder = new StringBuilder();
+ final String qualifierString = ((getQualifier() == null) ? Utils.EMPTY_STRING :
getQualifier());
+ final String nameString = ((getUnqualifiedName() == null) ? Utils.EMPTY_STRING :
getUnqualifiedName());
+
+ if (!Utils.isEmpty(qualifierString)) {
+ builder.append(qualifierString);
+ builder.append(DELIM);
+ }
+
+ if (!Utils.isEmpty(nameString)) {
+ builder.append(nameString);
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * @return the qualifier part (can be <code>null</code> or empty)
+ */
+ public String getQualifier() {
+ return this.qualifier.get();
+ }
+
+ /**
+ * @return the unqualified name part (can be <code>null</code> or empty)
+ */
+ public String getUnqualifiedName() {
+ return this.name.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return Utils.hashCode(this.qualifier, this.name);
+ }
+
+ /**
+ * @param newQualifiedName the proposed new qualified name (can be
<code>null</code> or empty)
+ * @return <code>true</code> if either the qualifier or unqualified name
was changed
+ */
+ public boolean set( final String newQualifiedName ) {
+ final QualifiedName temp = QualifiedName.parse(newQualifiedName);
+ final boolean qualifierChanged = setQualifier(temp.getQualifier());
+ final boolean nameChanged = setUnqualifiedName(temp.getUnqualifiedName());
+ return (qualifierChanged || nameChanged);
+ }
+
+ /**
+ * @param newMode the new mode (cannot be <code>null</code>)
+ * @return <code>true</code> if the mode was changed
+ */
+ public boolean setMode( final Mode newMode ) {
+ Utils.verifyIsNotNull(newMode, "newMode"); //$NON-NLS-1$
+
+ if (this.mode != newMode) {
+ this.mode = newMode;
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * @param newQualifier the proposed new qualifier (can be
<code>null</code> or empty)
+ * @return <code>true</code> if the qualifier part was changed
+ */
+ public boolean setQualifier( final String newQualifier ) {
+ return this.qualifier.set(newQualifier);
+ }
+
+ /**
+ * @param newUnqualifiedName the proposed new unqualified name (can be
<code>null</code> or empty)
+ * @return <code>true</code> if the unqualified name part was changed
+ */
+ public boolean setUnqualifiedName( final String newUnqualifiedName ) {
+ return this.name.set(newUnqualifiedName);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
+ */
+ @Override
+ public String toCndNotation( final NotationType notationType ) {
+ final String unqualifiedName = get();
+
+ if (Utils.isEmpty(unqualifiedName)) {
+ return Utils.EMPTY_STRING;
+ }
+
+ Mode notationMode = this.mode;
+
+ if ((this.mode == Mode.UNQOUTED) &&
unqualifiedName.contains(Utils.SPACE_STRING)) {
+ notationMode = Mode.SINGLE_QUOTED;
+ }
+
+ return (notationMode + unqualifiedName + notationMode);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return get();
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/QualifiedName.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/AttributeState.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -16,27 +16,6 @@
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 = '?';
@@ -139,7 +118,7 @@
* @return <code>true</code> if state was changed
*/
public boolean set( final Value newState ) {
- Utils.isNotNull(newState, "newState"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(newState, "newState"); //$NON-NLS-1$
if (this.state != newState) {
this.state = newState;
@@ -188,4 +167,25 @@
return cndNotation + AttributeState.VARIANT_CHAR;
}
+
+ /**
+ * 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
+ }
}
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultType.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -8,6 +8,8 @@
package org.jboss.tools.modeshape.jcr.cnd.attributes;
import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
+import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
import org.jboss.tools.modeshape.jcr.cnd.LocalName;
/**
@@ -76,15 +78,29 @@
*/
@Override
protected String getLongCndNotation() {
+ if (isVariant()) {
+ return getPrefix();
+ }
+
String defaultType = getDefaultType();
if (Utils.isEmpty(defaultType)) {
- return NOTATION;
+ return Utils.EMPTY_STRING;
}
- return NOTATION + defaultType;
+ return getPrefix() + defaultType;
}
+ private String getPrefix() {
+ String delim =
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_TYPE_END_PREFIX_DELIMITER);
+
+ if (Utils.isEmpty(delim)) {
+ return NOTATION;
+ }
+
+ return (NOTATION + delim);
+ }
+
/**
* {@inheritDoc} <strong>Can only be used to change to a variant state. Use
{@link DefaultType#setDefaultType(String)} to set to
* other states</strong>
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultValues.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -10,6 +10,8 @@
import java.util.Collection;
import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
+import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
/**
*
@@ -51,4 +53,13 @@
return NOTATION_PREFIX;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getQuoteCharacter()
+ */
+ @Override
+ protected String getQuoteCharacter() {
+ return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_QUOTE_CHARACTER);
+ }
}
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ListAttributeState.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -32,7 +32,7 @@
* @return <code>true</code> if successfully added
*/
public boolean add( final E item ) {
- Utils.isNotNull(item, "item"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(item, "item"); //$NON-NLS-1$
if (this.supported == null) {
this.supported = new ArrayList<E>();
@@ -138,6 +138,13 @@
}
/**
+ * @return the quote character (empty, single, or double) surrounding each item of
the list (cannot be <code>null</code>)
+ */
+ protected String getItemQuoteCharacter() {
+ return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
+ }
+
+ /**
* @return the delimiter used after the list prefix (never
<code>null</code> but can be empty)
*/
protected String getListPrefixEndDelimiter() {
@@ -155,6 +162,13 @@
}
/**
+ * @return the quote character (empty, single, double) surrounding the elements of
the list (cannot be <code>null</code>)
+ */
+ protected String getQuoteCharacter() {
+ return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR);
+ }
+
+ /**
* @return the collection of supported items (never <code>null</code>)
*/
public List<E> getSupportedItems() {
@@ -190,7 +204,7 @@
* @return <code>true</code> if successfully removed
*/
public boolean remove( final E item ) {
- Utils.isNotNull(item, "item"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(item, "item"); //$NON-NLS-1$
if (this.supported == null) {
return false;
@@ -236,29 +250,29 @@
return Utils.EMPTY_STRING;
}
- if (items.size() == 1) {
- final E firstItem = items.iterator().next();
-
- if (firstItem instanceof CndElement) {
- return ((CndElement)firstItem).toCndNotation(notationType);
- }
-
- return firstItem.toString();
- }
-
+ final String itemQuote = getItemQuoteCharacter();
+ final boolean useQuote = !Utils.isEmpty(itemQuote);
final StringBuilder builder = new StringBuilder();
for (final Iterator<E> itr = items.iterator(); itr.hasNext();) {
final E item = itr.next();
+ if (useQuote) {
+ builder.append(itemQuote);
+ }
+
if (item instanceof CndElement) {
builder.append(((CndElement)item).toCndNotation(notationType));
} else {
builder.append(item.toString());
}
+ if (useQuote) {
+ builder.append(itemQuote);
+ }
+
if (itr.hasNext()) {
- builder.append(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER);
+
builder.append(CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER));
}
}
@@ -270,7 +284,7 @@
* @return <code>true</code> if item is contained in list
*/
public boolean supports( final E item ) {
- Utils.isNotNull(item, "item"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(item, "item"); //$NON-NLS-1$
return this.supported.contains(item);
}
@@ -298,9 +312,9 @@
builder.append(AttributeState.VARIANT_CHAR);
} else {
// add the delimited list
-
builder.append(CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR));
+ builder.append(getQuoteCharacter());
builder.append(supportedItemsCndNotation(notationType));
-
builder.append(CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR));
+ builder.append(getQuoteCharacter());
}
if (!Utils.isEmpty(getCndNotationSuffix(notationType))) {
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeAttributes.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -130,7 +130,7 @@
* @return <code>true</code> if changed
*/
public boolean setOnParentVersion( final OnParentVersion newOpv ) {
- Utils.isNotNull(newOpv, "newOpv"); //$NON-NLS-1$
+ Utils.verifyIsNotNull(newOpv, "newOpv"); //$NON-NLS-1$
if (this.opv != newOpv) {
this.opv = newOpv;
@@ -163,75 +163,27 @@
*/
@Override
public String toCndNotation( final NotationType notationType ) {
- final String delim = getFormatDelimiter();
+ final String DELIM = getFormatDelimiter();
final StringBuilder builder = new StringBuilder();
- boolean addDelim = false;
- { // autocreated
- if (addDelim) {
- builder.append(delim);
- }
+ boolean addDelim = Utils.build(builder, false, DELIM,
this.autocreated.toCndNotation(notationType));
- final String notation = this.autocreated.toCndNotation(notationType);
-
- if (!Utils.isEmpty(notation)) {
- builder.append(notation);
- addDelim = true;
- }
+ if (Utils.build(builder, addDelim, DELIM,
this.mandatory.toCndNotation(notationType))) {
+ addDelim = true;
}
- { // mandatory
- if (addDelim) {
- builder.append(delim);
- }
-
- final String notation = this.mandatory.toCndNotation(notationType);
-
- if (!Utils.isEmpty(notation)) {
- builder.append(notation);
- addDelim = true;
- }
+ if (Utils.build(builder, addDelim, DELIM,
this.notDeletable.toCndNotation(notationType))) {
+ addDelim = true;
}
- { // protected
- if (addDelim) {
- builder.append(delim);
- }
-
- final String notation = this.notDeletable.toCndNotation(notationType);
-
- if (!Utils.isEmpty(notation)) {
- builder.append(notation);
- addDelim = true;
- }
+ if (Utils.build(builder, addDelim, DELIM, this.opv.toCndNotation(notationType)))
{
+ addDelim = true;
}
- { // on parent value
- if (addDelim) {
- builder.append(delim);
- }
-
- final String notation = this.opv.toCndNotation(notationType);
-
- if (!Utils.isEmpty(notation)) {
- builder.append(notation);
- addDelim = true;
- }
+ if (Utils.build(builder, addDelim, DELIM, this.sns.toCndNotation(notationType)))
{
+ addDelim = true;
}
- { // same name siblings
- if (addDelim) {
- builder.append(delim);
- }
-
- final String notation = this.sns.toCndNotation(notationType);
-
- if (!Utils.isEmpty(notation)) {
- builder.append(notation);
- addDelim = true;
- }
- }
-
return builder.toString().trim();
}
}
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeTypeAttributes.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -102,7 +102,7 @@
}
private String getFormatDelimiter() {
- return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER);
+ return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER);
}
/**
@@ -204,11 +204,23 @@
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));
- addDelim = Utils.build(builder, addDelim, DELIM,
this.notConcrete.toCndNotation(notationType));
- addDelim = Utils.build(builder, addDelim, DELIM,
this.queryable.toCndNotation(notationType));
- addDelim = Utils.build(builder, addDelim, DELIM,
this.primaryItem.toCndNotation(notationType));
+ if (Utils.build(builder, addDelim, DELIM,
this.mixin.toCndNotation(notationType))) {
+ addDelim = true;
+ }
+
+ if (Utils.build(builder, addDelim, DELIM,
this.notConcrete.toCndNotation(notationType))) {
+ addDelim = true;
+ }
+
+ if (Utils.build(builder, addDelim, DELIM,
this.queryable.toCndNotation(notationType))) {
+ addDelim = true;
+ }
+
+ if (Utils.build(builder, addDelim, DELIM,
this.primaryItem.toCndNotation(notationType))) {
+ addDelim = true;
+ }
+
return builder.toString().trim();
}
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyAttributes.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -266,14 +266,35 @@
StringBuilder builder = new StringBuilder();
boolean addDelim = Utils.build(builder, false, DELIM,
this.autocreated.toCndNotation(notationType));
- addDelim = Utils.build(builder, addDelim, DELIM,
this.mandatory.toCndNotation(notationType));
- addDelim = Utils.build(builder, addDelim, DELIM,
this.notDeletable.toCndNotation(notationType));
- addDelim = Utils.build(builder, addDelim, DELIM,
this.multiple.toCndNotation(notationType));
- addDelim = Utils.build(builder, addDelim, DELIM,
this.opv.toCndNotation(notationType));
- addDelim = Utils.build(builder, addDelim, DELIM,
this.noFullText.toCndNotation(notationType));
- addDelim = Utils.build(builder, addDelim, DELIM,
this.noQueryOrder.toCndNotation(notationType));
- addDelim = Utils.build(builder, addDelim, DELIM,
this.queryOps.toCndNotation(notationType));
+ if (Utils.build(builder, addDelim, DELIM,
this.mandatory.toCndNotation(notationType))) {
+ addDelim = true;
+ }
+
+ if (Utils.build(builder, addDelim, DELIM,
this.notDeletable.toCndNotation(notationType))) {
+ addDelim = true;
+ }
+
+ if (Utils.build(builder, addDelim, DELIM,
this.multiple.toCndNotation(notationType))) {
+ addDelim = true;
+ }
+
+ if (Utils.build(builder, addDelim, DELIM, this.opv.toCndNotation(notationType)))
{
+ addDelim = true;
+ }
+
+ if (Utils.build(builder, addDelim, DELIM,
this.noFullText.toCndNotation(notationType))) {
+ addDelim = true;
+ }
+
+ if (Utils.build(builder, addDelim, DELIM,
this.noQueryOrder.toCndNotation(notationType))) {
+ addDelim = true;
+ }
+
+ if (Utils.build(builder, addDelim, DELIM,
this.queryOps.toCndNotation(notationType))) {
+ addDelim = true;
+ }
+
return builder.toString().trim();
}
}
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyType.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -203,14 +203,4 @@
return builder.append(NOTATION_SUFFIX).toString();
}
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Enum#toString()
- */
- @Override
- public String toString() {
- return javax.jcr.PropertyType.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/RequiredTypes.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypes.java 2012-03-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypes.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -10,11 +10,12 @@
import java.util.List;
import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.cnd.QualifiedName;
/**
* The required types of a child node definition.
*/
-public final class RequiredTypes extends ListAttributeState<String> {
+public final class RequiredTypes extends ListAttributeState<QualifiedName> {
/**
* The CND list prefix.
@@ -60,7 +61,7 @@
* @return the collection of required types (never <code>null</code>)
*/
public String[] toArray() {
- final List<String> typeNames = getSupportedItems();
+ final List<QualifiedName> typeNames = getSupportedItems();
if (Utils.isEmpty(typeNames)) {
return Utils.EMPTY_STRING_ARRAY;
@@ -69,8 +70,8 @@
final String[] result = new String[typeNames.size()];
int i = 0;
- for (final String typeName : typeNames) {
- result[i++] = typeName;
+ for (final QualifiedName typeName : typeNames) {
+ result[i++] = typeName.get();
}
return result;
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ValueConstraints.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -10,6 +10,8 @@
import java.util.List;
import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
+import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
/**
* The value constraints of a property definition.
@@ -32,6 +34,16 @@
}
/**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getItemQuoteCharacter()
+ */
+ @Override
+ protected String getItemQuoteCharacter() {
+ return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER);
+ }
+
+ /**
* @return the collection of value constraints (never <code>null</code>)
*/
public String[] toArray() {
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties 2012-03-14
21:11:58 UTC (rev 39516)
@@ -49,6 +49,8 @@
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 = name or type of qualified name
+emptyUnqualifiedName = The "{0}" qualified name has an empty unqualified name.
# 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
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java 2012-03-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -12,9 +12,6 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import java.util.Collection;
-import java.util.Collections;
-
import org.jboss.tools.modeshape.jcr.Listener;
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.cnd.ChildNodeDefinition.PropertyName;
@@ -187,7 +184,7 @@
public void shouldReceiveEventAfterClearingSuperTypes() {
final String REQUIRED_TYPE = "requiredType"; //$NON-NLS-1$
assertTrue(this.childNodeDefinition.addRequiredType(REQUIRED_TYPE));
- Collection<String> oldValue = Collections.singletonList(REQUIRED_TYPE);
+ String[] oldValue = new String[] {REQUIRED_TYPE};
Listener l = new Listener();
assertTrue(this.childNodeDefinition.addListener(l));
@@ -196,7 +193,7 @@
assertEquals(1, l.getCount());
assertEquals(PropertyName.REQUIRED_TYPES.toString(), l.getPropertyName());
assertNull(l.getNewValue());
- assertEquals(oldValue, l.getOldValue());
+ assertEquals(oldValue[0], ((String[])l.getOldValue())[0]);
}
@Test
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-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -8,6 +8,7 @@
package org.jboss.tools.modeshape.jcr.cnd;
import org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType;
+import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
import org.jboss.tools.modeshape.jcr.cnd.attributes.Abstract;
import org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState;
import org.jboss.tools.modeshape.jcr.cnd.attributes.Autocreated;
@@ -21,6 +22,7 @@
import org.jboss.tools.modeshape.jcr.cnd.attributes.Orderable;
import org.jboss.tools.modeshape.jcr.cnd.attributes.PrimaryItem;
import org.jboss.tools.modeshape.jcr.cnd.attributes.Protected;
+import org.jboss.tools.modeshape.jcr.cnd.attributes.QueryOperators;
import org.jboss.tools.modeshape.jcr.cnd.attributes.QueryOperators.QueryOperator;
import org.jboss.tools.modeshape.jcr.cnd.attributes.RequiredTypes;
import org.jboss.tools.modeshape.jcr.cnd.attributes.SameNameSiblings;
@@ -32,6 +34,18 @@
*/
public interface Constants {
+ String QUALIFIER1 = "QUALIFIER1"; //$NON-NLS-1$
+ String QUALIFIER2 = "QUALIFIER2"; //$NON-NLS-1$
+ String QUALIFIER3 = "QUALIFIER3"; //$NON-NLS-1$
+
+ String UNQUALIFIED_NAME1 = "UNQUALIFIED_NAME1"; //$NON-NLS-1$
+ String UNQUALIFIED_NAME2 = "UNQUALIFIED_NAME2"; //$NON-NLS-1$
+ String UNQUALIFIED_NAME3 = "UNQUALIFIED_NAME3"; //$NON-NLS-1$
+
+ QualifiedName QUALIFIED_NAME1 = new QualifiedName(QUALIFIER1, UNQUALIFIED_NAME1);
+ QualifiedName QUALIFIED_NAME2 = new QualifiedName(QUALIFIER2, UNQUALIFIED_NAME2);
+ QualifiedName QUALIFIED_NAME3 = new QualifiedName(QUALIFIER3, UNQUALIFIED_NAME3);
+
String VARIANT = AttributeState.VARIANT_STRING;
String ABSTRACT_VARIANT_COMPACT_FORM = Abstract.NOTATION[NotationType.COMPACT_INDEX]
+ VARIANT;
@@ -42,9 +56,11 @@
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
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_TYPE_END_PREFIX_DELIMITER)
+ 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
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_TYPE_END_PREFIX_DELIMITER)
+ DEFAULT_TYPE;
String MANDATORY_VARIANT_COMPACT_FORM =
Mandatory.NOTATION[NotationType.COMPACT_INDEX] + VARIANT;
String MANDATORY_VARIANT_COMPRESSED_FORM =
Mandatory.NOTATION[NotationType.COMPRESSED_INDEX] + VARIANT;
@@ -82,37 +98,54 @@
String PROTECTED_VARIANT_COMPRESSED_FORM =
Protected.NOTATION[NotationType.COMPRESSED_INDEX] + VARIANT;
String PROTECTED_VARIANT_LONG_FORM = Protected.NOTATION[NotationType.LONG_INDEX] +
VARIANT;
- String QUERY_OPS_COMPACT_FORM = "qop"; //$NON-NLS-1$
- String QUERY_OPS_COMPRESSED_FORM = "qop"; //$NON-NLS-1$
- String QUERY_OPS_LONG_FORM = "queryops"; //$NON-NLS-1$
- String QUERY_OPS_VARIANT_COMPACT_FORM = QUERY_OPS_COMPACT_FORM + ' ' +
VARIANT;
- String QUERY_OPS_VARIANT_COMPRESSED_FORM = QUERY_OPS_COMPRESSED_FORM + ' ' +
VARIANT;
- String QUERY_OPS_VARIANT_LONG_FORM = QUERY_OPS_LONG_FORM + ' ' + VARIANT;
+ String QUERY_OPS_COMPACT_FORM = QueryOperators.NOTATION[NotationType.COMPACT_INDEX]
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER);
+ String QUERY_OPS_COMPRESSED_FORM =
QueryOperators.NOTATION[NotationType.COMPRESSED_INDEX]
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER);
+ String QUERY_OPS_LONG_FORM = QueryOperators.NOTATION[NotationType.LONG_INDEX]
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER);
+ String QUERY_OPS_VARIANT_COMPACT_FORM = QUERY_OPS_COMPACT_FORM + VARIANT;
+ String QUERY_OPS_VARIANT_COMPRESSED_FORM = QUERY_OPS_COMPRESSED_FORM + VARIANT;
+ String QUERY_OPS_VARIANT_LONG_FORM = QUERY_OPS_LONG_FORM + VARIANT;
QueryOperator OPERATOR_ONE = QueryOperator.EQUALS;
QueryOperator OPERATOR_TWO = QueryOperator.GREATER_THAN;
QueryOperator OPERATOR_THREE = QueryOperator.LESS_THAN;
- String QUERY_OPS_ONE_OPERATOR_COMPACT_FORM = QUERY_OPS_COMPACT_FORM + "
'" + OPERATOR_ONE.toCndNotation(NotationType.COMPACT) //$NON-NLS-1$
- + '\'';
- 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_ONE_OPERATOR_COMPACT_FORM = QUERY_OPS_COMPACT_FORM
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ + OPERATOR_ONE.toCndNotation(NotationType.COMPACT)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
+ String QUERY_OPS_ONE_OPERATOR_COMPRESSED_FORM = QUERY_OPS_COMPRESSED_FORM
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ + OPERATOR_ONE.toCndNotation(NotationType.COMPRESSED)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
+ String QUERY_OPS_ONE_OPERATOR_LONG_FORM = QUERY_OPS_LONG_FORM
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ + OPERATOR_ONE.toCndNotation(NotationType.LONG)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
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) + '\'';
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ + OPERATOR_ONE.toCndNotation(NotationType.COMPACT)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ + OPERATOR_TWO.toCndNotation(NotationType.COMPACT)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ + OPERATOR_THREE.toCndNotation(NotationType.COMPACT)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
String QUERY_OPS_THREE_OPERATOR_COMPRESSED_FORM = QUERY_OPS_COMPRESSED_FORM
- + " '" //$NON-NLS-1$
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ OPERATOR_ONE.toCndNotation(NotationType.COMPRESSED)
- + CndNotationPreferences.Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ OPERATOR_TWO.toCndNotation(NotationType.COMPRESSED)
- + CndNotationPreferences.Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER
- + OPERATOR_THREE.toCndNotation(NotationType.COMPRESSED) + '\'';
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ + OPERATOR_THREE.toCndNotation(NotationType.COMPRESSED)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
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)
- + '\'';
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ + OPERATOR_ONE.toCndNotation(NotationType.LONG)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ + OPERATOR_TWO.toCndNotation(NotationType.LONG)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ + OPERATOR_THREE.toCndNotation(NotationType.LONG)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
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;
@@ -121,25 +154,68 @@
String ITEM_ONE = "item1"; //$NON-NLS-1$
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 +
CndNotationPreferences.Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER
- + ITEM_TWO +
CndNotationPreferences.Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER + ITEM_THREE +
'\'';
+ String ONE_ITEM_SINGLE_QUOTED_FORM =
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR)
+ + ITEM_ONE +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR);
+ String THREE_ITEM_SINGLE_QUOTED_FORM =
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR)
+ + ITEM_ONE +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ ITEM_TWO
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ ITEM_THREE
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR);
- String DEFAULT_VALUES_VARIANT = DefaultValues.NOTATION_PREFIX + ' ' +
VARIANT;
- String DEFAULT_VALUES_ONE_ITEM_FORM = DefaultValues.NOTATION_PREFIX + ' ' +
ONE_ITEM_SINGLE_QUOTED_FORM;
- String DEFAULT_VALUES_THREE_ITEM_FORM = DefaultValues.NOTATION_PREFIX + ' ' +
THREE_ITEM_SINGLE_QUOTED_FORM;
+ String DEFAULT_VALUES_VARIANT = DefaultValues.NOTATION_PREFIX
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_END_PREFIX_DELIMITER)
+ VARIANT;
+ String DEFAULT_VALUES_ONE_ITEM_FORM = DefaultValues.NOTATION_PREFIX
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_END_PREFIX_DELIMITER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_QUOTE_CHARACTER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ ITEM_ONE
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_QUOTE_CHARACTER);
+ String DEFAULT_VALUES_THREE_ITEM_FORM = DefaultValues.NOTATION_PREFIX
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_END_PREFIX_DELIMITER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_QUOTE_CHARACTER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ ITEM_ONE
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ ITEM_TWO
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ ITEM_THREE
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_QUOTE_CHARACTER);
String REQUIRED_TYPES_VARIANT = RequiredTypes.NOTATION_PREFIX + VARIANT +
RequiredTypes.NOTATION_SUFFIX;
- String REQUIRED_TYPES_ONE_ITEM_FORM = RequiredTypes.NOTATION_PREFIX +
ONE_ITEM_SINGLE_QUOTED_FORM
+ String REQUIRED_TYPES_ONE_ITEM_FORM = RequiredTypes.NOTATION_PREFIX +
QUALIFIED_NAME1.get() + RequiredTypes.NOTATION_SUFFIX;
+ String REQUIRED_TYPES_THREE_ITEM_FORM = RequiredTypes.NOTATION_PREFIX +
QUALIFIED_NAME1.get()
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ QUALIFIED_NAME2.get()
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ QUALIFIED_NAME3.get()
+ RequiredTypes.NOTATION_SUFFIX;
- String REQUIRED_TYPES_THREE_ITEM_FORM = RequiredTypes.NOTATION_PREFIX +
THREE_ITEM_SINGLE_QUOTED_FORM
- + RequiredTypes.NOTATION_SUFFIX;
- String SUPER_TYPES_VARIANT = SuperTypes.NOTATION_PREFIX + ' ' + VARIANT;
- String SUPER_TYPES_ONE_ITEM_FORM = SuperTypes.NOTATION_PREFIX + ' ' +
ONE_ITEM_SINGLE_QUOTED_FORM;
- String SUPER_TYPES_THREE_ITEM_FORM = SuperTypes.NOTATION_PREFIX + ' ' +
THREE_ITEM_SINGLE_QUOTED_FORM;
+ String SUPER_TYPES_VARIANT = SuperTypes.NOTATION_PREFIX
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER)
+ VARIANT;
+ String SUPER_TYPES_ONE_ITEM_FORM = SuperTypes.NOTATION_PREFIX
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER)
+ + ONE_ITEM_SINGLE_QUOTED_FORM;
+ String SUPER_TYPES_THREE_ITEM_FORM = SuperTypes.NOTATION_PREFIX
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER)
+ + THREE_ITEM_SINGLE_QUOTED_FORM;
- String VALUE_CONSTRAINTS_VARIANT = ValueConstraints.NOTATION_PREFIX + ' ' +
VARIANT;
- String VALUE_CONSTRAINTS_ONE_ITEM_FORM = ValueConstraints.NOTATION_PREFIX + '
' + ONE_ITEM_SINGLE_QUOTED_FORM;
- String VALUE_CONSTRAINTS_THREE_ITEM_FORM = ValueConstraints.NOTATION_PREFIX + '
' + THREE_ITEM_SINGLE_QUOTED_FORM;
+ String VALUE_CONSTRAINTS_VARIANT = ValueConstraints.NOTATION_PREFIX
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER)
+ VARIANT;
+ String VALUE_CONSTRAINTS_ONE_ITEM_FORM = ValueConstraints.NOTATION_PREFIX
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
+ ITEM_ONE
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR);
+ String VALUE_CONSTRAINTS_THREE_ITEM_FORM = ValueConstraints.NOTATION_PREFIX
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
+ ITEM_ONE
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
+ ITEM_TWO
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
+ ITEM_THREE
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR);
}
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java 2012-03-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -430,13 +430,14 @@
Listener l = new Listener();
assertTrue(this.nodeTypeDefinition.addListener(l));
+ final String OLD_NAME = this.nodeTypeDefinition.getName();
final String NEW_NAME = "newName"; //$NON-NLS-1$
this.nodeTypeDefinition.setName(NEW_NAME);
assertEquals(1, l.getCount());
assertEquals(PropertyName.NAME.toString(), l.getPropertyName());
assertEquals(NEW_NAME, l.getNewValue());
- assertNull(l.getOldValue());
+ assertEquals(OLD_NAME, l.getOldValue());
}
@Test
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java 2012-03-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -479,13 +479,13 @@
Listener l = new Listener();
assertTrue(this.propDefn.addListener(l));
- final String NAME = "name"; //$NON-NLS-1$
- this.propDefn.setName(NAME);
+ final String NEW_NAME = "name"; //$NON-NLS-1$
+ this.propDefn.setName(NEW_NAME);
- assertEquals(NAME, this.propDefn.getName());
+ assertEquals(NEW_NAME, this.propDefn.getName());
assertEquals(1, l.getCount());
assertEquals(PropertyName.NAME.toString(), l.getPropertyName());
- assertEquals(NAME, l.getNewValue());
+ assertEquals(NEW_NAME, l.getNewValue());
assertNull(l.getOldValue());
}
Added:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/QualifiedNameTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/QualifiedNameTest.java
(rev 0)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/QualifiedNameTest.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
+ */
+package org.jboss.tools.modeshape.jcr.cnd;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.jboss.tools.modeshape.jcr.Utils;
+import org.junit.Before;
+import org.junit.Test;
+
+public class QualifiedNameTest {
+
+ private QualifiedName qualifiedName;
+
+ @Before
+ public void beforeEach() {
+ this.qualifiedName = new QualifiedName();
+ }
+
+ @Test
+ public void noArgConstructorShouldNotHaveQualifier() {
+ assertTrue(Utils.isEmpty(this.qualifiedName.getQualifier()));
+ }
+
+ @Test
+ public void noArgConstructorShouldNotHaveUnqualifiedName() {
+ assertTrue(Utils.isEmpty(this.qualifiedName.getUnqualifiedName()));
+ }
+
+ @Test
+ public void shouldSetQualifierAtConstructor() {
+ final String QUALIFIER = "qualifier"; //$NON-NLS-1$
+ this.qualifiedName = new QualifiedName(QUALIFIER, null);
+ assertEquals(QUALIFIER, this.qualifiedName.getQualifier());
+ }
+
+ @Test
+ public void shouldSetUnqualifiedNameAtConstructor() {
+ final String NAME = "unqualifiedName"; //$NON-NLS-1$
+ this.qualifiedName = new QualifiedName(null, NAME);
+ assertEquals(NAME, this.qualifiedName.getUnqualifiedName());
+ }
+
+ @Test
+ public void shouldAllowNullValuesAtConstructor() {
+ new QualifiedName(null, null);
+ }
+
+ @Test
+ public void shouldParseQualifiedName() {
+ final String QUALIFIER = "qualifier"; //$NON-NLS-1$
+ final String NAME = "unqualifiedName"; //$NON-NLS-1$
+ final String QUALIFIED_NAME = QUALIFIER + QualifiedName.DELIM + NAME;
+ QualifiedName qualifiedName = QualifiedName.parse(QUALIFIED_NAME);
+ assertEquals(QUALIFIER, qualifiedName.getQualifier());
+ assertEquals(NAME, qualifiedName.getUnqualifiedName());
+ }
+
+ @Test
+ public void twoQualifiedNamesWithSameQualifierAndNameShouldBeEqual() {
+ final String QUALIFIER = "qualifier"; //$NON-NLS-1$
+ final String NAME = "unqualifiedName"; //$NON-NLS-1$
+ QualifiedName qn1 = new QualifiedName(QUALIFIER, NAME);
+ QualifiedName qn2 = new QualifiedName(QUALIFIER, NAME);
+ assertEquals(qn1, qn2);
+ }
+
+ @Test
+ public void twoQualifiedNamesWithSameQualifierAndNameShouldHaveSameHashCode() {
+ final String QUALIFIER = "qualifier"; //$NON-NLS-1$
+ final String NAME = "unqualifiedName"; //$NON-NLS-1$
+ QualifiedName qn1 = new QualifiedName(QUALIFIER, NAME);
+ QualifiedName qn2 = new QualifiedName(QUALIFIER, NAME);
+ assertEquals(qn1.hashCode(), qn2.hashCode());
+ }
+
+ @Test
+ public void twoQualifiedNamesWithSameQualifierAndDifferentNamesShouldNotBeEqual() {
+ final String QUALIFIER = "qualifier"; //$NON-NLS-1$
+ final String NAME = "unqualifiedName"; //$NON-NLS-1$
+ QualifiedName qn1 = new QualifiedName(QUALIFIER, NAME);
+ QualifiedName qn2 = new QualifiedName(QUALIFIER, NAME + "Changed");
//$NON-NLS-1$
+ assertFalse(qn1.equals(qn2));
+ }
+
+ @Test
+ public void twoQualifiedNamesWithDifferentQualifiersAndSameNameShouldNotBeEqual() {
+ final String QUALIFIER = "qualifier"; //$NON-NLS-1$
+ final String NAME = "unqualifiedName"; //$NON-NLS-1$
+ QualifiedName qn1 = new QualifiedName(QUALIFIER, NAME);
+ QualifiedName qn2 = new QualifiedName(QUALIFIER + "Changed", NAME);
//$NON-NLS-1$
+ assertFalse(qn1.equals(qn2));
+ }
+
+ @Test
+ public void shouldSetWithQualifiedName() {
+ final String QUALIFIER = "qualifier"; //$NON-NLS-1$
+ final String NAME = "unqualifiedName"; //$NON-NLS-1$
+ final String QUALIFIED_NAME = QUALIFIER + QualifiedName.DELIM + NAME;
+ assertTrue(this.qualifiedName.set(QUALIFIED_NAME));
+ assertEquals(QUALIFIER, this.qualifiedName.getQualifier());
+ assertEquals(NAME, this.qualifiedName.getUnqualifiedName());
+ }
+
+ @Test
+ public void shouldSetQualifier() {
+ final String QUALIFIER = "qualifier"; //$NON-NLS-1$
+ assertTrue(this.qualifiedName.setQualifier(QUALIFIER));
+ assertEquals(QUALIFIER, this.qualifiedName.getQualifier());
+ }
+
+ @Test
+ public void shouldNotSetQualifierToSameValue() {
+ final String QUALIFIER = "qualifier"; //$NON-NLS-1$
+ assertTrue(this.qualifiedName.setQualifier(QUALIFIER));
+ assertFalse(this.qualifiedName.setQualifier(QUALIFIER));
+ }
+
+ @Test
+ public void shouldSetUnqualifiedName() {
+ final String NAME = "unqualifiedName"; //$NON-NLS-1$
+ assertTrue(this.qualifiedName.setUnqualifiedName(NAME));
+ assertEquals(NAME, this.qualifiedName.getUnqualifiedName());
+ }
+
+ @Test
+ public void shouldNotSetUnqualifiedNameToSameValue() {
+ final String NAME = "unqualifiedName"; //$NON-NLS-1$
+ assertTrue(this.qualifiedName.setUnqualifiedName(NAME));
+ assertFalse(this.qualifiedName.setUnqualifiedName(NAME));
+ }
+
+ @Test
+ public void shouldNotHaveQualifierWhenSettingWithJustUnqualifiedName() {
+ final String NAME = "unqualifiedName"; //$NON-NLS-1$
+ assertTrue(this.qualifiedName.set(NAME));
+ assertTrue(Utils.isEmpty(this.qualifiedName.getQualifier()));
+ assertEquals(NAME, this.qualifiedName.getUnqualifiedName());
+ }
+
+ @Test
+ public void shouldNotHaveUnqualifiedNameWhenSettingWithJustQualifier() {
+ final String QUALIFIER = "qualifier"; //$NON-NLS-1$
+ assertTrue(this.qualifiedName.set(QUALIFIER + QualifiedName.DELIM));
+ assertTrue(Utils.isEmpty(this.qualifiedName.getUnqualifiedName()));
+ assertEquals(QUALIFIER, this.qualifiedName.getQualifier());
+ }
+
+}
Property changes on:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/QualifiedNameTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypesTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypesTest.java 2012-03-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypesTest.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -15,6 +15,7 @@
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
import org.jboss.tools.modeshape.jcr.cnd.Constants;
+import org.jboss.tools.modeshape.jcr.cnd.QualifiedName;
import org.junit.Before;
import org.junit.Test;
@@ -25,13 +26,13 @@
private RequiredTypes attribute;
- private void add( String item ) {
+ private void add( QualifiedName item ) {
if (!this.attribute.add(item)) {
fail();
}
}
- private void remove( String item ) {
+ private void remove( QualifiedName item ) {
if (!this.attribute.remove(item)) {
fail();
}
@@ -52,11 +53,11 @@
@Test
public void verifyAddedItem() {
// setup
- add(ITEM_ONE);
+ add(QUALIFIED_NAME1);
// tests
assertEquals(1, this.attribute.getSupportedItems().size());
- assertTrue(this.attribute.getSupportedItems().contains(ITEM_ONE));
+ assertTrue(this.attribute.getSupportedItems().contains(QUALIFIED_NAME1));
}
@Test
@@ -72,9 +73,9 @@
@Test
public void verifyMultipleElementsCndNotation() {
// setup
- add(ITEM_ONE);
- add(ITEM_TWO);
- add(ITEM_THREE);
+ add(QUALIFIED_NAME1);
+ add(QUALIFIED_NAME2);
+ add(QUALIFIED_NAME3);
// tests
assertEquals(REQUIRED_TYPES_THREE_ITEM_FORM,
this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
@@ -85,7 +86,7 @@
@Test
public void verifyOneElementCndNotation() {
// setup
- add(ITEM_ONE);
+ add(QUALIFIED_NAME1);
// tests
assertEquals(REQUIRED_TYPES_ONE_ITEM_FORM,
this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
@@ -96,21 +97,21 @@
@Test
public void verifyRemoveItem() {
// setup
- add(ITEM_ONE);
- add(ITEM_TWO);
- remove(ITEM_ONE);
+ add(QUALIFIED_NAME1);
+ add(QUALIFIED_NAME2);
+ remove(QUALIFIED_NAME1);
// tests
- assertFalse(this.attribute.getSupportedItems().contains(ITEM_ONE));
+ assertFalse(this.attribute.getSupportedItems().contains(QUALIFIED_NAME1));
}
@Test
public void verifySameElementIsNotAdded() {
// setup
- add(ITEM_ONE);
+ add(QUALIFIED_NAME1);
// tests
- if (this.attribute.add(ITEM_ONE)) {
+ if (this.attribute.add(QUALIFIED_NAME1)) {
fail();
}
@@ -120,7 +121,7 @@
@Test
public void verifyStateShouldBeIsAfterAdd() {
// setup
- add(ITEM_ONE);
+ add(QUALIFIED_NAME1);
// tests
assertEquals(AttributeState.Value.IS, this.attribute.get());
@@ -129,8 +130,8 @@
@Test
public void verifyStateShouldBeIsNotWhenEmpty() {
// setup
- add(ITEM_ONE);
- remove(ITEM_ONE);
+ add(QUALIFIED_NAME1);
+ remove(QUALIFIED_NAME1);
// tests
assertEquals(0, this.attribute.getSupportedItems().size());
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/test/AllTests.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/test/AllTests.java 2012-03-14
18:25:37 UTC (rev 39515)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/test/AllTests.java 2012-03-14
21:11:58 UTC (rev 39516)
@@ -15,6 +15,7 @@
import org.jboss.tools.modeshape.jcr.cnd.LocalNameTest;
import org.jboss.tools.modeshape.jcr.cnd.NamespaceMappingTest;
import org.jboss.tools.modeshape.jcr.cnd.PropertyDefinitionTest;
+import org.jboss.tools.modeshape.jcr.cnd.QualifiedNameTest;
import org.jboss.tools.modeshape.jcr.cnd.attributes.AbstractTest;
import org.jboss.tools.modeshape.jcr.cnd.attributes.AutocreatedTest;
import org.jboss.tools.modeshape.jcr.cnd.attributes.DefaultTypeTest;
@@ -46,11 +47,11 @@
@RunWith(Suite.class)
@Suite.SuiteClasses({ ChildNodeDefinitionTest.class, CndImporterTest.class,
CndTokenizerTest.class, CndValidatorTest.class,
CompactNodeTypeDefinitionTest.class, LocalNameTest.class,
NamespaceMappingTest.class, PropertyDefinitionTest.class,
- AbstractTest.class, AutocreatedTest.class, DefaultTypeTest.class,
DefaultValuesTest.class, MandatoryTest.class,
- MixinTest.class, MultipleTest.class, NodeAttributesTest.class,
NodeTypeAttributesTest.class, NoFullTextTest.class,
- NoQueryOrderTest.class, OnParentValueTest.class, OrderableTest.class,
PrimaryItemTest.class, PropertyAttributesTest.class,
- ProtectedTest.class, QueryableTest.class, QueryOperatorsTest.class,
RequiredTypesTest.class, SameNameSiblingsTest.class,
- SuperTypesTest.class, ValueConstraintsTest.class })
+ QualifiedNameTest.class, AbstractTest.class, AutocreatedTest.class,
DefaultTypeTest.class, DefaultValuesTest.class,
+ MandatoryTest.class, MixinTest.class, MultipleTest.class,
NodeAttributesTest.class, NodeTypeAttributesTest.class,
+ NoFullTextTest.class, NoQueryOrderTest.class, OnParentValueTest.class,
OrderableTest.class, PrimaryItemTest.class,
+ PropertyAttributesTest.class, ProtectedTest.class, QueryableTest.class,
QueryOperatorsTest.class, RequiredTypesTest.class,
+ SameNameSiblingsTest.class, SuperTypesTest.class, ValueConstraintsTest.class })
public class AllTests {
// nothing to do
}
Added:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/jsr_283_builtins.cnd
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/jsr_283_builtins.cnd
(rev 0)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/jsr_283_builtins.cnd 2012-03-14
21:11:58 UTC (rev 39516)
@@ -0,0 +1,183 @@
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+
+// ------------------------------------------------------------------------
+// Pre-defined Node Types
+// ------------------------------------------------------------------------
+
+[nt:base] abstract
+ - jcr:primaryType (name) mandatory autocreated
+ protected compute
+ - jcr:mixinTypes (name) protected multiple compute
+
+[nt:unstructured]
+ orderable
+ - * (undefined) multiple
+ - * (undefined)
+ + * (nt:base) = nt:unstructured sns version
+
+[mix:created] mixin
+ - jcr:created (date) protected
+ - jcr:createdBy (string) protected
+
+[nt:hierarchyNode] > mix:created abstract
+
+[nt:file] > nt:hierarchyNode
+ + jcr:content (nt:base) primary mandatory
+
+[nt:linkedFile] > nt:hierarchyNode
+ - jcr:content (reference) primary mandatory
+
+[nt:folder] > nt:hierarchyNode
+ + * (nt:hierarchyNode) version
+
+[mix:referenceable] mixin
+ - jcr:uuid (string) mandatory autocreated protected initialize
+
+[mix:mimeType] mixin
+ - jcr:mimeType (string)
+ - jcr:encoding (string)
+
+[mix:lastModified] mixin
+ - jcr:lastModified (date)
+ - jcr:lastModifiedBy (string)
+
+[nt:resource] > mix:mimeType, mix:lastModified
+ - jcr:data (binary) primary mandatory
+
+[nt:nodeType]
+ - jcr:nodeTypeName (name) mandatory protected copy
+ - jcr:supertypes (name) multiple protected copy
+ - jcr:isAbstract (boolean) mandatory protected copy
+ - jcr:isMixin (boolean) mandatory protected copy
+ - jcr:isQueryable (boolean) mandatory protected copy
+ - jcr:hasOrderableChildNodes (boolean) mandatory protected copy
+ - jcr:primaryItemName (name) protected copy
+ + jcr:propertyDefinition (nt:propertyDefinition) = nt:propertyDefinition sns protected
copy
+ + jcr:childNodeDefinition (nt:childNodeDefinition) = nt:childNodeDefinition sns
protected copy
+
+[nt:propertyDefinition]
+ - jcr:name (name) protected
+ - jcr:autoCreated (boolean) mandatory protected
+ - jcr:mandatory (boolean) mandatory protected
+ - jcr:isFullTextSearchable (boolean) mandatory protected
+ - jcr:isQueryOrderable (boolean) mandatory protected
+ - jcr:onParentVersion (string) mandatory protected
+ < 'COPY', 'VERSION', 'INITIALIZE', 'COMPUTE',
+ 'IGNORE', 'ABORT'
+ - jcr:protected (boolean) mandatory protected
+ - jcr:requiredType (string) mandatory protected
+ < 'STRING', 'URI', 'BINARY', 'LONG',
'DOUBLE', 'DECIMAL', 'BOOLEAN',
+ 'DATE', 'NAME', 'PATH', 'REFERENCE',
'WEAKREFERENCE', 'UNDEFINED'
+ - jcr:valueConstraints (string) multiple protected
+ - jcr:availableQueryOperators (name) mandatory multiple protected
+ - jcr:defaultValues (undefined) multiple protected
+ - jcr:multiple (boolean) mandatory protected
+
+[nt:childNodeDefinition]
+ - jcr:name (name) protected
+ - jcr:autoCreated (boolean) mandatory protected
+ - jcr:mandatory (boolean) mandatory protected
+ - jcr:onParentVersion (string) mandatory protected
+ < 'COPY', 'VERSION', 'INITIALIZE', 'COMPUTE',
+ 'IGNORE', 'ABORT'
+ - jcr:protected (boolean) mandatory protected
+ - jcr:requiredPrimaryTypes (name) = 'nt:base' mandatory protected multiple
+ - jcr:defaultPrimaryType (name) protected
+ - jcr:sameNameSiblings (boolean) mandatory protected
+
+[nt:versionHistory] > mix:referenceable
+ - jcr:versionableUuid (string) mandatory autocreated protected abort
+ - jcr:copiedFrom (weakreference) protected abort < 'nt:version'
+ + jcr:rootVersion (nt:version) = nt:version mandatory autocreated protected abort
+ + jcr:versionLabels (nt:versionLabels) = nt:versionLabels mandatory autocreated
protected abort
+ + * (nt:version) = nt:version protected abort
+
+
+[nt:versionLabels]
+ - * (reference) protected abort < 'nt:version'
+
+[nt:version] > mix:referenceable
+ - jcr:created (date) mandatory autocreated protected abort
+ - jcr:predecessors (reference) protected multiple abort < 'nt:version'
+ - jcr:successors (reference) protected multiple abort < 'nt:version'
+ - jcr:activity (reference) protected abort < 'nt:activity'
+ + jcr:frozenNode (nt:frozenNode) protected abort
+
+[nt:frozenNode] > mix:referenceable
+ orderable
+ - jcr:frozenPrimaryType (name) mandatory autocreated protected abort
+ - jcr:frozenMixinTypes (name) protected multiple abort
+ - jcr:frozenUuid (string) mandatory autocreated protected abort
+ - * (undefined) protected abort
+ - * (undefined) protected multiple abort
+ + * (nt:base) protected sns abort
+
+[nt:versionedChild]
+ - jcr:childVersionHistory (reference) mandatory autocreated protected abort <
'nt:versionHistory'
+
+[nt:query]
+ - jcr:statement (string)
+ - jcr:language (string)
+
+[nt:activity] > mix:referenceable
+ - jcr:activityTitle (string) mandatory autocreated protected
+
+
+[mix:simpleVersionable] mixin
+ - jcr:isCheckedOut (boolean) = 'true' mandatory autocreated protected ignore
+
+[mix:versionable] > mix:simpleVersionable, mix:referenceable mixin
+ - jcr:versionHistory (reference) mandatory protected ignore <
'nt:versionHistory'
+ - jcr:baseVersion (reference) mandatory protected ignore < 'nt:version'
+ - jcr:predecessors (reference) mandatory protected multiple ignore <
'nt:version'
+ - jcr:mergeFailed (reference) protected multiple abort
+ - jcr:activity (reference) protected < 'nt:version'
+ - jcr:configuration (reference) protected ignore < 'nt:configuration'
+
+[nt:configuration] > mix:versionable
+ - jcr:root (reference) mandatory autocreated protected
+
+[nt:address]
+ - jcr:protocol (string)
+ - jcr:host (string)
+ - jcr:port (string)
+ - jcr:repository (string)
+ - jcr:workspace (string)
+ - jcr:path (path)
+ - jcr:id (weakreference)
+
+[nt:naturalText]
+ - jcr:text (string)
+ - jcr:messageId (string)
+
+
+// ------------------------------------------------------------------------
+// Pre-defined Mixins
+// ------------------------------------------------------------------------
+
+[mix:etag] mixin
+ - jcr:etag (string) protected autocreated
+
+[mix:lockable] mixin
+ - jcr:lockOwner (string) protected ignore
+ - jcr:lockIsDeep (boolean) protected ignore
+
+[mix:lifecycle] mixin
+ - jcr:lifecyclePolicy (reference) protected initialize
+ - jcr:currentLifecycleState (string) protected initialize
+
+[mix:managedRetention] > mix:referenceable mixin
+ - jcr:hold (string) protected multiple
+ - jcr:isDeep (boolean) protected multiple
+ - jcr:retentionPolicy (reference) protected
+
+[mix:shareable] > mix:referenceable mixin
+
+[mix:title] mixin
+ - jcr:title (string)
+ - jcr:description (string)
+
+[mix:language] mixin
+ - jcr:language (string)