jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r816120 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/ jac...
Date Thu, 17 Sep 2009 10:03:06 GMT
Author: mreutegg
Date: Thu Sep 17 10:03:05 2009
New Revision: 816120

URL: http://svn.apache.org/viewvc?rev=816120&view=rev
Log:
JCR-2308: Allow reuse of Q*DefinitionBuilder in QItemDefinitionsBuilder

Added:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/DefinitionBuilderFactory.java   (contents, props changed)
      - copied, changed from r814655, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/AbstractItemTypeDefinitionsBuilder.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/TemplateBuilderFactory.java   (contents, props changed)
      - copied, changed from r814655, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/ItemTemplatesBuilder.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QDefinitionBuilderFactory.java   (contents, props changed)
      - copied, changed from r814655, jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QItemDefinitionsBuilder.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QItemDefinitionBuilder.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QNodeDefinitionBuilder.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QPropertyDefinitionBuilder.java   (with props)
Removed:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/AbstractItemTypeDefinitionsBuilder.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/ItemTemplatesBuilder.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QItemDefinitionsBuilder.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/CndImporter.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/CompactNodeTypeDefReader.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java?rev=816120&r1=816119&r2=816120&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java Thu Sep 17 10:03:05 2009
@@ -39,7 +39,7 @@
 import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
-import org.apache.jackrabbit.spi.commons.nodetype.QItemDefinitionsBuilder;
+import org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory;
 import org.apache.jackrabbit.spi.commons.nodetype.compact.CompactNodeTypeDefWriter;
 
 /**
@@ -253,7 +253,7 @@
             CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping> reader =
                 new CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping>(
                     sr, "(internal)", new NamespaceMapping(nsResolver),
-                    new QItemDefinitionsBuilder());
+                    new QDefinitionBuilderFactory());
 
             Collection<QNodeTypeDefinition> ntds = reader.getNodeTypeDefinitions();
             if (ntds.size() != 1) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java?rev=816120&r1=816119&r2=816120&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeDefStore.java Thu Sep 17 10:03:05 2009
@@ -35,7 +35,7 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
-import org.apache.jackrabbit.spi.commons.nodetype.QItemDefinitionsBuilder;
+import org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory;
 
 /**
  * <code>NodeTypeDefStore</code> ...
@@ -80,7 +80,7 @@
         try {
             CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping> r =
                 new CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping>(
-                    in, systemId, new QItemDefinitionsBuilder());
+                    in, systemId, new QDefinitionBuilderFactory());
 
             for (QNodeTypeDefinition qdef: r.getNodeTypeDefinitions()) {
                 add(new NodeTypeDef(qdef));

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java?rev=816120&r1=816119&r2=816120&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java Thu Sep 17 10:03:05 2009
@@ -66,7 +66,7 @@
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
 import org.apache.jackrabbit.spi.commons.nodetype.AbstractNodeTypeManager;
 import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
-import org.apache.jackrabbit.spi.commons.nodetype.QItemDefinitionsBuilder;
+import org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory;
 import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -272,7 +272,7 @@
                     CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping> reader =
                         new CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping>(
                             new InputStreamReader(in), "cnd input stream", mapping,
-                            new QItemDefinitionsBuilder());
+                            new QDefinitionBuilderFactory());
 
                     namespaceMap.putAll(mapping.getPrefixToURIMapping());
                     for (QNodeTypeDefinition ntDef: reader.getNodeTypeDefinitions()) {

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/CndImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/CndImporter.java?rev=816120&r1=816119&r2=816120&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/CndImporter.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/CndImporter.java Thu Sep 17 10:03:05 2009
@@ -39,7 +39,7 @@
 /**
  * Utility class for importing compact node type definitions.
  * @see CompactNodeTypeDefReader
- * @see ItemTemplatesBuilder
+ * @see TemplateBuilderFactory
  */
 public final class CndImporter {
 
@@ -105,11 +105,11 @@
             UnsupportedRepositoryOperationException, RepositoryException, IOException {
 
         try {
-            AbstractItemTypeDefinitionsBuilder<NodeTypeTemplate, NamespaceRegistry> builder =
-                    new ItemTemplatesBuilder(nodeTypeManager, valueFactory, namespaceRegistry);
+            DefinitionBuilderFactory<NodeTypeTemplate, NamespaceRegistry> factory =
+                    new TemplateBuilderFactory(nodeTypeManager, valueFactory, namespaceRegistry);
 
             CompactNodeTypeDefReader<NodeTypeTemplate, NamespaceRegistry> cndReader =
-                new CompactNodeTypeDefReader<NodeTypeTemplate, NamespaceRegistry>(cnd, systemId, builder);
+                new CompactNodeTypeDefReader<NodeTypeTemplate, NamespaceRegistry>(cnd, systemId, factory);
 
             List<NodeTypeTemplate> ntts = cndReader.getNodeTypeDefinitions();
 

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/CompactNodeTypeDefReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/CompactNodeTypeDefReader.java?rev=816120&r1=816119&r2=816120&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/CompactNodeTypeDefReader.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/CompactNodeTypeDefReader.java Thu Sep 17 10:03:05 2009
@@ -25,9 +25,9 @@
 import javax.jcr.query.qom.QueryObjectModelConstants;
 import javax.jcr.version.OnParentVersionAction;
 
-import org.apache.jackrabbit.commons.cnd.AbstractItemTypeDefinitionsBuilder.AbstractNodeDefinitionBuilder;
-import org.apache.jackrabbit.commons.cnd.AbstractItemTypeDefinitionsBuilder.AbstractNodeTypeDefinitionBuilder;
-import org.apache.jackrabbit.commons.cnd.AbstractItemTypeDefinitionsBuilder.AbstractPropertyDefinitionBuilder;
+import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory.AbstractNodeDefinitionBuilder;
+import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory.AbstractNodeTypeDefinitionBuilder;
+import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory.AbstractPropertyDefinitionBuilder;
 
 /**
  * CompactNodeTypeDefReader. Parses node type definitions written in the compact
@@ -37,7 +37,7 @@
  * The CompactNodeTypeDefReader is parameterizable in the type of the node type
  * definition <code>T</code> and the type of the namespace mapping <code>N</code>
  * which the parser should build. For types <code>T</code> and <code>N</code> the
- * parser's constructor takes a {@link AbstractItemTypeDefinitionsBuilder} for
+ * parser's constructor takes a {@link DefinitionBuilderFactory} for
  * <code>T</code> and <code>N</code>.
  *
  * <p/>
@@ -124,20 +124,20 @@
     /**
      * The builder for QNodeTypeDefinitions
      */
-    private final AbstractItemTypeDefinitionsBuilder<T, N> builder;
+    private final DefinitionBuilderFactory<T, N> factory;
 
     /**
      * Creates a new CND reader and parses the given stream.
      *
      * @param r a reader to the CND
      * @param systemId a informative id of the given stream
-     * @param builder builder for creating new definitions and handling namespaces
+     * @param factory builder for creating new definitions and handling namespaces
      * @throws ParseException if an error occurs
      */
     public CompactNodeTypeDefReader(Reader r, String systemId,
-            AbstractItemTypeDefinitionsBuilder<T, N> builder) throws ParseException {
+            DefinitionBuilderFactory<T, N> factory) throws ParseException {
 
-        this(r, systemId, null, builder);
+        this(r, systemId, null, factory);
     }
 
     /**
@@ -146,18 +146,18 @@
      * @param r a reader to the CND
      * @param systemId a informative id of the given stream
      * @param nsMapping default namespace mapping to use
-     * @param builder builder for creating new definitions and handling namespaces
+     * @param factory builder for creating new definitions and handling namespaces
      * @throws ParseException if an error occurs
      */
     public CompactNodeTypeDefReader(Reader r, String systemId, N nsMapping,
-            AbstractItemTypeDefinitionsBuilder<T, N> builder) throws ParseException {
+            DefinitionBuilderFactory<T, N> factory) throws ParseException {
 
         super();
 
-        this.builder = builder;
+        this.factory = factory;
         lexer = new Lexer(r, systemId);
         if (nsMapping != null) {
-            builder.setNamespaceMapping(nsMapping);
+            factory.setNamespaceMapping(nsMapping);
         }
 
         nextToken();
@@ -187,7 +187,7 @@
      * @return
      */
     public N getNamespaceMapping() {
-        return builder.getNamespaceMapping();
+        return factory.getNamespaceMapping();
     }
 
     /**
@@ -203,7 +203,7 @@
         }
         try {
             while (!currentTokenEquals(Lexer.EOF)) {
-                AbstractNodeTypeDefinitionBuilder<T> ntd = builder.newNodeTypeDefinitionBuilder();
+                AbstractNodeTypeDefinitionBuilder<T> ntd = factory.newNodeTypeDefinitionBuilder();
                 ntd.setOrderableChildNodes(false);
                 ntd.setMixin(false);
                 ntd.setAbstract(false);
@@ -244,7 +244,7 @@
             lexer.fail("Missing > in namespace decl.");
         }
         try {
-            builder.setNamespace(prefix, uri);
+            factory.setNamespace(prefix, uri);
         }
         catch (RepositoryException e) {
             lexer.fail("Error setting namespace mapping " + currentToken, e);

Copied: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/DefinitionBuilderFactory.java (from r814655, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/AbstractItemTypeDefinitionsBuilder.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/DefinitionBuilderFactory.java?p2=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/DefinitionBuilderFactory.java&p1=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/AbstractItemTypeDefinitionsBuilder.java&r1=814655&r2=816120&rev=816120&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/AbstractItemTypeDefinitionsBuilder.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/DefinitionBuilderFactory.java Thu Sep 17 10:03:05 2009
@@ -26,7 +26,7 @@
  * @param <T>  type of the node type definition
  * @param <N>  type of the namespace mapping
  */
-public abstract class AbstractItemTypeDefinitionsBuilder<T, N> {
+public abstract class DefinitionBuilderFactory<T, N> {
 
     /**
      * Create a new instance of a {@link AbstractNodeTypeDefinitionBuilder}
@@ -149,7 +149,7 @@
         }
 
         /**
-         * Create a new instance of a {@link AbstractItemTypeDefinitionsBuilder.AbstractPropertyDefinitionBuilder}
+         * Create a new instance of a {@link DefinitionBuilderFactory.AbstractPropertyDefinitionBuilder}
          * which can be used to add property definitions to the node type definition being built.
          * @return
          * @throws RepositoryException
@@ -158,7 +158,7 @@
                 throws RepositoryException;
 
         /**
-         * Create a new instance fo a {@link AbstractItemTypeDefinitionsBuilder.AbstractNodeDefinitionBuilder}
+         * Create a new instance fo a {@link DefinitionBuilderFactory.AbstractNodeDefinitionBuilder}
          * which can be used to add child node definitions to the node type definition being built.
          * @return
          * @throws RepositoryException

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/DefinitionBuilderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/DefinitionBuilderFactory.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Copied: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/TemplateBuilderFactory.java (from r814655, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/ItemTemplatesBuilder.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/TemplateBuilderFactory.java?p2=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/TemplateBuilderFactory.java&p1=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/ItemTemplatesBuilder.java&r1=814655&r2=816120&rev=816120&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/ItemTemplatesBuilder.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/TemplateBuilderFactory.java Thu Sep 17 10:03:05 2009
@@ -33,21 +33,20 @@
 
 
 /**
- * This implementation of {@link AbstractItemTypeDefinitionsBuilder} can be used with
+ * This implementation of {@link DefinitionBuilderFactory} can be used with
  * the {@link CompactNodeTypeDefReader} to produce node type definitions of type
  * {@link NodeTypeTemplate} and a namespace map of type {@link NamespaceRegistry}.
  * It uses {@link NodeTypeTemplateBuilder} for building node type definitions,
  * {@link PropertyDefinitionTemplateBuilder} for building property definitions, and
  * {@link NodeDefinitionTemplateBuilder} for building node definitions.
  */
-public class ItemTemplatesBuilder extends
-        AbstractItemTypeDefinitionsBuilder<NodeTypeTemplate, NamespaceRegistry> {
+public class TemplateBuilderFactory extends DefinitionBuilderFactory<NodeTypeTemplate, NamespaceRegistry> {
 
     private final NodeTypeManager nodeTypeManager;
     private final ValueFactory valueFactory;
     private NamespaceRegistry namespaceRegistry;
 
-    public ItemTemplatesBuilder(NodeTypeManager nodeTypeManager, ValueFactory valueFactory,
+    public TemplateBuilderFactory(NodeTypeManager nodeTypeManager, ValueFactory valueFactory,
             NamespaceRegistry namespaceRegistry) {
 
         this.nodeTypeManager = nodeTypeManager;

Propchange: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/TemplateBuilderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java?rev=816120&r1=816119&r2=816120&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java Thu Sep 17 10:03:05 2009
@@ -77,7 +77,7 @@
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeStorage;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeStorageImpl;
-import org.apache.jackrabbit.spi.commons.nodetype.QItemDefinitionsBuilder;
+import org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory;
 import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
 
 /**
@@ -209,7 +209,7 @@
         CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping> reader;
         try {
             reader = new CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping>(cnd, "",
-                    this.namespaces, new QItemDefinitionsBuilder());
+                    this.namespaces, new QDefinitionBuilderFactory());
 
             List<QNodeTypeDefinition> ntds = reader.getNodeTypeDefinitions();
             nodeTypeDefs.registerNodeTypes(ntds.toArray(new QNodeTypeDefinition[ntds.size()]), true);

Copied: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QDefinitionBuilderFactory.java (from r814655, jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QItemDefinitionsBuilder.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QDefinitionBuilderFactory.java?p2=jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QDefinitionBuilderFactory.java&p1=jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QItemDefinitionsBuilder.java&r1=814655&r2=816120&rev=816120&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QItemDefinitionsBuilder.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QDefinitionBuilderFactory.java Thu Sep 17 10:03:05 2009
@@ -22,18 +22,14 @@
 import javax.jcr.NamespaceException;
 import javax.jcr.RepositoryException;
 
-import org.apache.jackrabbit.commons.cnd.AbstractItemTypeDefinitionsBuilder;
+import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory;
 import org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NameFactory;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
-import org.apache.jackrabbit.spi.QValue;
-import org.apache.jackrabbit.spi.QValueConstraint;
-import org.apache.jackrabbit.spi.commons.QNodeDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
-import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
@@ -41,23 +37,21 @@
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
 import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
-import org.apache.jackrabbit.spi.commons.query.qom.Operator;
 import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.apache.jackrabbit.util.ISO9075;
 
 /**
- * This implementation of {@link AbstractItemTypeDefinitionsBuilder} can be used with
+ * This implementation of {@link DefinitionBuilderFactory} can be used with
  * the {@link CompactNodeTypeDefReader} to produce node type definitions of type
  * {@link QNodeTypeDefinition} and a namespace map of type {@link NamespaceMapping}.
- * It uses {@link QNodeTypeDefinitionBuilder} for building node type definitions,
- * {@link QPropertyDefinitionBuilder} for building property definitions, and
- * {@link QNodeDefinitionBuilder} for building node definitions. It further uses
+ * It uses {@link QNodeTypeDefinitionBuilderImpl} for building node type definitions,
+ * {@link QPropertyDefinitionBuilderImpl} for building property definitions, and
+ * {@link QNodeDefinitionBuilderImpl} for building node definitions. It further uses
  * {@link NameFactoryImpl} for creating <code>Name</code>s and {@link QValueFactoryImpl} for
  * creating <code>QValue</code>s.
  */
-public class QItemDefinitionsBuilder extends
-        AbstractItemTypeDefinitionsBuilder<QNodeTypeDefinition, NamespaceMapping> {
+public class QDefinitionBuilderFactory extends DefinitionBuilderFactory<QNodeTypeDefinition, NamespaceMapping> {
 
     private static final NameFactory NAME_FACTORY = NameFactoryImpl.getInstance();
 
@@ -83,7 +77,7 @@
 
     @Override
     public AbstractNodeTypeDefinitionBuilder<QNodeTypeDefinition> newNodeTypeDefinitionBuilder() {
-        return new QNodeTypeDefinitionBuilder();
+        return new QNodeTypeDefinitionBuilderImpl();
     }
 
     @Override
@@ -107,7 +101,7 @@
         }
     }
 
-    public class QNodeTypeDefinitionBuilder extends AbstractNodeTypeDefinitionBuilder<QNodeTypeDefinition> {
+    private class QNodeTypeDefinitionBuilderImpl extends AbstractNodeTypeDefinitionBuilder<QNodeTypeDefinition> {
         private Name name;
         private final List<Name> supertypes = new ArrayList<Name>();
         private Name primaryItem;
@@ -116,12 +110,12 @@
 
         @Override
         public AbstractNodeDefinitionBuilder<QNodeTypeDefinition> newNodeDefinitionBuilder() {
-            return new QNodeDefinitionBuilder(this);
+            return new QNodeDefinitionBuilderImpl(this);
         }
 
         @Override
         public AbstractPropertyDefinitionBuilder<QNodeTypeDefinition> newPropertyDefinitionBuilder() {
-            return new QPropertyDefinitionBuilder(this);
+            return new QPropertyDefinitionBuilderImpl(this);
         }
 
         @Override
@@ -157,14 +151,12 @@
 
     }
 
-    public class QPropertyDefinitionBuilder extends AbstractPropertyDefinitionBuilder<QNodeTypeDefinition> {
-        private Name name;
-        private final QNodeTypeDefinitionBuilder ntd;
-        private final List<QValue> values = new ArrayList<QValue>();
-        private final List<QValueConstraint> constraints = new ArrayList<QValueConstraint>();
-        private Name declaringType;
+    private class QPropertyDefinitionBuilderImpl extends AbstractPropertyDefinitionBuilder<QNodeTypeDefinition> {
+
+        private final QNodeTypeDefinitionBuilderImpl ntd;
+        private final QPropertyDefinitionBuilder builder = new QPropertyDefinitionBuilder();
 
-        public QPropertyDefinitionBuilder(QNodeTypeDefinitionBuilder ntd) {
+        public QPropertyDefinitionBuilderImpl(QNodeTypeDefinitionBuilderImpl ntd) {
             super();
             this.ntd = ntd;
         }
@@ -173,60 +165,101 @@
         public void setName(String name) throws RepositoryException {
             super.setName(name);
             if ("*".equals(name)) {
-                this.name = NameConstants.ANY_NAME;
+                builder.setName(NameConstants.ANY_NAME);
             }
             else {
-                this.name = toName(name);
+                builder.setName(toName(name));
             }
         }
 
         @Override
+        public void setRequiredType(int type) throws RepositoryException {
+            super.setRequiredType(type);
+            builder.setRequiredType(type);
+        }
+
+        @Override
+        public void setMultiple(boolean isMultiple) throws RepositoryException {
+            super.setMultiple(isMultiple);
+            builder.setMultiple(isMultiple);
+        }
+
+        @Override
+        public void setFullTextSearchable(boolean fullTextSearchable)
+                throws RepositoryException {
+            super.setFullTextSearchable(fullTextSearchable);
+            builder.setFullTextSearchable(fullTextSearchable);
+        }
+
+        @Override
+        public void setQueryOrderable(boolean queryOrderable)
+                throws RepositoryException {
+            super.setQueryOrderable(queryOrderable);
+            builder.setQueryOrderable(queryOrderable);
+        }
+
+        @Override
+        public void setAvailableQueryOperators(String[] queryOperators)
+                throws RepositoryException {
+            super.setAvailableQueryOperators(queryOperators);
+            builder.setAvailableQueryOperators(queryOperators);
+        }
+
+        @Override
+        public void setAutoCreated(boolean autocreate)
+                throws RepositoryException {
+            super.setAutoCreated(autocreate);
+            builder.setAutoCreated(autocreate);
+        }
+
+        @Override
+        public void setOnParentVersion(int onParent)
+                throws RepositoryException {
+            super.setOnParentVersion(onParent);
+            builder.setOnParentVersion(onParent);
+        }
+
+        @Override
+        public void setProtected(boolean isProtected)
+                throws RepositoryException {
+            super.setProtected(isProtected);
+            builder.setProtected(isProtected);
+        }
+
+        @Override
+        public void setMandatory(boolean isMandatory)
+                throws RepositoryException {
+            super.setMandatory(isMandatory);
+            builder.setMandatory(isMandatory);
+        }
+
+        @Override
         public void addDefaultValues(String value) throws RepositoryException {
-            values.add(ValueFormat.getQValue(value, getRequiredType(), resolver, QValueFactoryImpl.getInstance()));
+            builder.addDefaultValue(ValueFormat.getQValue(value, getRequiredType(), resolver, QValueFactoryImpl.getInstance()));
         }
 
         @Override
         public void addValueConstraint(String constraint) throws InvalidConstraintException {
-            constraints.add(ValueConstraint.create(getRequiredType(), constraint, resolver));
+            builder.addValueConstraint(ValueConstraint.create(getRequiredType(), constraint, resolver));
         }
 
         @Override
         public void setDeclaringNodeType(String name) throws IllegalNameException, NamespaceException {
-            this.declaringType = toName(name);
+            builder.setDeclaringNodeType(toName(name));
         }
 
         @Override
         public void build() throws IllegalStateException {
-            if (queryOperators == null) {
-                queryOperators = Operator.getAllQueryOperators();
-            }
-
-            ntd.propertyDefs.add(new QPropertyDefinitionImpl(
-                    name,
-                    declaringType,
-                    super.autocreate,
-                    super.isMandatory,
-                    super.onParent,
-                    super.isProtected,
-                    values.toArray(new QValue[values.size()]),
-                    super.isMultiple,
-                    super.requiredType,
-                    constraints.toArray(new QValueConstraint[constraints.size()]),
-                    super.queryOperators,
-                    super.fullTextSearchable,
-                    super.queryOrderable));
+            ntd.propertyDefs.add(builder.build());
         }
-
     }
 
-    public class QNodeDefinitionBuilder extends AbstractNodeDefinitionBuilder<QNodeTypeDefinition> {
-        private final QNodeTypeDefinitionBuilder ntd;
-        private Name name;
-        private final List<Name> requiredPrimaryTypes = new ArrayList<Name>();
-        private Name defaultPrimaryType;
-        private Name declaringNodeType;
+    private class QNodeDefinitionBuilderImpl extends AbstractNodeDefinitionBuilder<QNodeTypeDefinition> {
+        private final QNodeTypeDefinitionBuilderImpl ntd;
+
+        private final QNodeDefinitionBuilder builder = new QNodeDefinitionBuilder();
 
-        public QNodeDefinitionBuilder(QNodeTypeDefinitionBuilder ntd) {
+        public QNodeDefinitionBuilderImpl(QNodeTypeDefinitionBuilderImpl ntd) {
             super();
             this.ntd = ntd;
         }
@@ -235,46 +268,71 @@
         public void setName(String name) throws RepositoryException {
             super.setName(name);
             if ("*".equals(name)) {
-                this.name = NameConstants.ANY_NAME;
+                builder.setName(NameConstants.ANY_NAME);
             }
             else {
-                this.name = toName(name);
+                builder.setName(toName(name));
             }
         }
 
         @Override
+        public void setAllowsSameNameSiblings(boolean allowSns)
+                throws RepositoryException {
+            super.setAllowsSameNameSiblings(allowSns);
+            builder.setAllowsSameNameSiblings(allowSns);
+        }
+
+        @Override
+        public void setAutoCreated(boolean autocreate)
+                throws RepositoryException {
+            super.setAutoCreated(autocreate);
+            builder.setAutoCreated(autocreate);
+        }
+
+        @Override
+        public void setOnParentVersion(int onParent)
+                throws RepositoryException {
+            super.setOnParentVersion(onParent);
+            builder.setOnParentVersion(onParent);
+        }
+
+        @Override
+        public void setProtected(boolean isProtected)
+                throws RepositoryException {
+            super.setProtected(isProtected);
+            builder.setProtected(isProtected);
+        }
+
+        @Override
+        public void setMandatory(boolean isMandatory)
+                throws RepositoryException {
+            super.setMandatory(isMandatory);
+            builder.setMandatory(isMandatory);
+        }
+
+        @Override
         public void addRequiredPrimaryType(String name) throws IllegalNameException, NamespaceException {
-            requiredPrimaryTypes.add(toName(name));
+            builder.addRequiredPrimaryType(toName(name));
         }
 
         @Override
         public void setDefaultPrimaryType(String name) throws IllegalNameException, NamespaceException {
-            defaultPrimaryType = toName(name);
+            builder.setDefaultPrimaryType(toName(name));
         }
 
         @Override
         public void setDeclaringNodeType(String name) throws IllegalNameException, NamespaceException {
-            declaringNodeType = toName(name);
+            builder.setDeclaringNodeType(toName(name));
         }
 
         @Override
         public void build() {
-            if (requiredPrimaryTypes.isEmpty()) {
-                requiredPrimaryTypes.add(NameConstants.NT_BASE);
+            if (builder.getRequiredPrimaryTypes() == null) {
+                builder.addRequiredPrimaryType(NameConstants.NT_BASE);
             }
 
-            ntd.childNodeDefs.add(new QNodeDefinitionImpl(
-                    name,
-                    declaringNodeType,
-                    super.autocreate,
-                    super.isMandatory,
-                    super.onParent,
-                    super.isProtected,
-                    defaultPrimaryType,
-                    requiredPrimaryTypes.toArray(new Name[requiredPrimaryTypes.size()]),
-                    super.allowSns));
+            ntd.childNodeDefs.add(builder.build());
         }
-
     }
 
 

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QDefinitionBuilderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QDefinitionBuilderFactory.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QItemDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QItemDefinitionBuilder.java?rev=816120&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QItemDefinitionBuilder.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QItemDefinitionBuilder.java Thu Sep 17 10:03:05 2009
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.commons.nodetype;
+
+import javax.jcr.nodetype.ItemDefinition;
+
+import org.apache.jackrabbit.spi.QItemDefinition;
+import org.apache.jackrabbit.spi.Name;
+
+/**
+ * A builder for {@link QItemDefinition}.
+ */
+public abstract class QItemDefinitionBuilder {
+
+    private Name name;
+    private Name declaringType;
+    private boolean isAutocreated;
+    private int onParentVersion;
+    private boolean isProtected;
+    private boolean isMandatory;
+
+    /**
+     * @param name  the name of the child item definition being build
+     * @see ItemDefinition#getName()
+     */
+    public void setName(Name name) {
+        this.name = name;
+    }
+
+    /**
+     * @return the name of the child item definition being build.
+     * @see ItemDefinition#getName()
+     */
+    public Name getName() {
+        return name;
+    }
+
+    /**
+     * @param type  the name of the declaring node type.
+     * @see ItemDefinition#getDeclaringNodeType()
+     */
+    public void setDeclaringNodeType(Name type) {
+        declaringType = type;
+    }
+
+    /**
+     * @return the name of the declaring node type.
+     * @see ItemDefinition#getDeclaringNodeType()
+     */
+    public Name getDeclaringNodeType() {
+        return declaringType;
+    }
+
+    /**
+     * @param autocreate <code>true</code> if building a 'autocreate' child item
+     * definition, false otherwise.
+     * @see ItemDefinition#isAutoCreated()
+     */
+    public void setAutoCreated(boolean autocreate) {
+        isAutocreated = autocreate;
+    }
+
+    /**
+     * @return <code>true</code> if building a 'autocreate' child item
+     * definition, false otherwise.
+     * @see ItemDefinition#isAutoCreated()
+     */
+    public boolean getAutoCreated() {
+        return isAutocreated;
+    }
+
+    /**
+     * @param onParent the 'onParentVersion' attribute of the child item definition being built
+     * @see ItemDefinition#getOnParentVersion()
+     */
+    public void setOnParentVersion(int onParent) {
+        onParentVersion = onParent;
+    }
+
+    /**
+     * @return the 'onParentVersion' attribute of the child item definition being built
+     * @see ItemDefinition#getOnParentVersion()
+     */
+    public int getOnParentVersion() {
+        return onParentVersion;
+    }
+
+    /**
+     * @param isProtected <code>true</code> if building a 'protected' child
+     * item definition, false otherwise.
+     * @see ItemDefinition#isProtected()
+     */
+    public void setProtected(boolean isProtected) {
+        this.isProtected = isProtected;
+    }
+
+    /**
+     * @return <code>true</code> if building a 'protected' child item
+     * definition, false otherwise.
+     * @see ItemDefinition#isProtected()
+     */
+    public boolean getProtected() {
+        return isProtected;
+    }
+
+    /**
+     * @param isMandatory <code>true</code> if building a 'mandatory' child
+     * item definition, false otherwise.
+     * @see ItemDefinition#isMandatory()
+     */
+    public void setMandatory(boolean isMandatory) {
+        this.isMandatory = isMandatory;
+    }
+
+    /**
+     * @return <code>true</code> if building a 'mandatory' child item
+     * definition, false otherwise.
+     * @see ItemDefinition#isMandatory()
+     */
+    public boolean getMandatory() {
+        return isMandatory;
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QItemDefinitionBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QNodeDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QNodeDefinitionBuilder.java?rev=816120&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QNodeDefinitionBuilder.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QNodeDefinitionBuilder.java Thu Sep 17 10:03:05 2009
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.commons.nodetype;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.commons.QNodeDefinitionImpl;
+
+/**
+ * A builder for a {@link QNodeDefinition}.
+ */
+public class QNodeDefinitionBuilder extends QItemDefinitionBuilder {
+
+    private Name defaultPrimaryType;
+    private List<Name> requiredPrimaryTypes;
+    private boolean allowsSameNameSiblings;
+
+    /**
+     * @param name the name of the default primary type of the node definition
+     *             being built.
+     */
+    public void setDefaultPrimaryType(Name name) {
+        defaultPrimaryType = name;
+    }
+
+    /**
+     * @return the name of the default primary type of the node definition being
+     *         built.
+     */
+    public Name getDefaultPrimaryType() {
+        return defaultPrimaryType;
+    }
+
+    /**
+     * Adds a required primary type of the node definition being built.
+     *
+     * @param name the name of a required primary type.
+     */
+    public void addRequiredPrimaryType(Name name) {
+        if (requiredPrimaryTypes == null) {
+            requiredPrimaryTypes = new ArrayList<Name>();
+        }
+        requiredPrimaryTypes.add(name);
+    }
+
+    /**
+     * @param names array of names of the required primary types of the node
+     *              definition being built.
+     */
+    public void setRequiredPrimaryTypes(Name[] names) {
+        if (names == null) {
+            requiredPrimaryTypes = null;
+        } else {
+            requiredPrimaryTypes = new ArrayList<Name>(Arrays.asList(names));
+        }
+    }
+
+    /**
+     * @return array of names of the required primary types of the node
+     *         definition being built.
+     */
+    public Name[] getRequiredPrimaryTypes() {
+        if (requiredPrimaryTypes == null) {
+            return null;
+        } else {
+            return requiredPrimaryTypes.toArray(new Name[requiredPrimaryTypes.size()]);
+        }
+    }
+
+    /**
+     * @param allowSns true if building a node definition with same name
+     *                 siblings, false otherwise.
+     */
+    public void setAllowsSameNameSiblings(boolean allowSns) {
+        allowsSameNameSiblings = allowSns;
+    }
+
+    /**
+     * @return true if building a node definition with same name siblings, false
+     *         otherwise.
+     */
+    public boolean getAllowsSameNameSiblings() {
+        return allowsSameNameSiblings;
+    }
+
+    /**
+     * Creates a new {@link QNodeDefinition} instance based on the state of this
+     * builder.
+     *
+     * @return a new {@link QNodeDefinition} instance.
+     * @throws IllegalStateException if the instance has not the necessary
+     *                               information to build the QNodeDefinition
+     *                               instance.
+     */
+    public QNodeDefinition build() throws IllegalStateException {
+        return new QNodeDefinitionImpl(getName(), getDeclaringNodeType(), getAutoCreated(), getMandatory(), getOnParentVersion(), getProtected(), getDefaultPrimaryType(), getRequiredPrimaryTypes(), getAllowsSameNameSiblings());
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QNodeDefinitionBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QPropertyDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QPropertyDefinitionBuilder.java?rev=816120&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QPropertyDefinitionBuilder.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QPropertyDefinitionBuilder.java Thu Sep 17 10:03:05 2009
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi.commons.nodetype;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import javax.jcr.nodetype.PropertyDefinition;
+
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.commons.query.qom.Operator;
+import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl;
+
+/**
+ * A builder for {@link QPropertyDefinition}.
+ */
+public class QPropertyDefinitionBuilder extends QItemDefinitionBuilder {
+
+    private int requiredType;
+    private List<QValueConstraint> valueConstraints = new ArrayList<QValueConstraint>();
+    private List<QValue> defaultValues;
+    private boolean isMultiple;
+    private boolean fullTextSearchable = true;
+    private boolean queryOrderable = true;
+    private String[] queryOperators = Operator.getAllQueryOperators();
+
+    /**
+     * @param type the required type of the property definition being built.
+     * @see PropertyDefinition#getRequiredType()
+     */
+    public void setRequiredType(int type) {
+        requiredType = type;
+    }
+
+    /**
+     * @return the required type of the property definition being built.
+     * @see PropertyDefinition#getRequiredType()
+     */
+    public int getRequiredType() {
+        return requiredType;
+    }
+
+    /**
+     * Adds a value constraint of the property definition being built.
+     *
+     * @param constraint the constraint.
+     */
+    public void addValueConstraint(QValueConstraint constraint) {
+        valueConstraints.add(constraint);
+    }
+
+    /**
+     * @param constraints array of value constraints of the property definition
+     *                    being built.
+     * @see PropertyDefinition#getValueConstraints()
+     */
+    public void setValueConstraints(QValueConstraint[] constraints) {
+        valueConstraints.clear();
+        valueConstraints.addAll(Arrays.asList(constraints));
+    }
+
+    /**
+     * @return array of value constraints of the property definition being
+     *         built.
+     * @see PropertyDefinition#getValueConstraints()
+     */
+    public QValueConstraint[] getValueConstraints() {
+        return valueConstraints.toArray(new QValueConstraint[valueConstraints.size()]);
+    }
+
+    /**
+     * Adds a default value of the property definition being built.
+     *
+     * @param value a default value.
+     */
+    public void addDefaultValue(QValue value) {
+        if (defaultValues == null) {
+            defaultValues = new ArrayList<QValue>();
+        }
+        defaultValues.add(value);
+    }
+
+    /**
+     * @param values array of default values of the property definition being
+     *               built.
+     * @see PropertyDefinition#getDefaultValues()
+     */
+    public void setDefaultValues(QValue[] values) {
+        if (values == null) {
+            defaultValues = null;
+        } else {
+            // replace
+            defaultValues = new ArrayList<QValue>(Arrays.asList(values));
+        }
+    }
+
+    /**
+     * @return array of default values of the property definition being built or
+     *         <code>null</code> if no default values are defined.
+     * @see PropertyDefinition#getDefaultValues()
+     */
+    public QValue[] getDefaultValues() {
+        if (defaultValues == null) {
+            return null;
+        } else {
+            return defaultValues.toArray(new QValue[defaultValues.size()]);
+        }
+    }
+
+    /**
+     * @param isMultiple true if building a 'multiple' property definition.
+     * @see PropertyDefinition#isMultiple()
+     */
+    public void setMultiple(boolean isMultiple) {
+        this.isMultiple = isMultiple;
+    }
+
+    /**
+     * @return true if building a 'multiple' property definition.
+     * @see PropertyDefinition#isMultiple()
+     */
+    public boolean getMultiple() {
+        return isMultiple;
+    }
+
+    /**
+     * @return <code>true</code> if the property is fulltext searchable
+     * @see PropertyDefinition#isFullTextSearchable()
+     */
+    public boolean getFullTextSearchable() {
+        return fullTextSearchable;
+    }
+
+    /**
+     * @param fullTextSearchable <code>true</code> if building a 'fulltext
+     *                           searchable' property definition
+     * @see PropertyDefinition#isFullTextSearchable()
+     */
+    public void setFullTextSearchable(boolean fullTextSearchable) {
+        this.fullTextSearchable = fullTextSearchable;
+    }
+
+    /**
+     * @return <code>true</code> if the property is orderable in a query
+     * @see PropertyDefinition#isQueryOrderable()
+     */
+    public boolean getQueryOrderable() {
+        return queryOrderable;
+    }
+
+    /**
+     * @param queryOrderable <code>true</code> if the property is orderable in a
+     *                       query
+     * @see PropertyDefinition#isQueryOrderable()
+     */
+    public void setQueryOrderable(boolean queryOrderable) {
+        this.queryOrderable = queryOrderable;
+    }
+
+    /**
+     * @return the query operators of the property
+     * @see PropertyDefinition#getAvailableQueryOperators()
+     */
+    public String[] getAvailableQueryOperators() {
+        return queryOperators;
+    }
+
+    /**
+     * @param queryOperators the query operators of the property
+     * @see PropertyDefinition#getAvailableQueryOperators()
+     */
+    public void setAvailableQueryOperators(String[] queryOperators) {
+        this.queryOperators = queryOperators;
+    }
+
+    /**
+     * Creates a new {@link QPropertyDefinition} instance based on the state of
+     * this builder.
+     *
+     * @return a new {@link QPropertyDefinition} instance.
+     * @throws IllegalStateException if the instance has not the necessary
+     *                               information to build the QPropertyDefinition
+     *                               instance.
+     */
+    public QPropertyDefinition build() throws IllegalStateException {
+        return new QPropertyDefinitionImpl(getName(), getDeclaringNodeType(), getAutoCreated(), getMandatory(), getOnParentVersion(), getProtected(), getDefaultValues(), getMultiple(), getRequiredType(), getValueConstraints(), getAvailableQueryOperators(), getFullTextSearchable(), getQueryOrderable());
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/QPropertyDefinitionBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefTest.java?rev=816120&r1=816119&r2=816120&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefTest.java Thu Sep 17 10:03:05 2009
@@ -31,7 +31,7 @@
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeDefDiff;
-import org.apache.jackrabbit.spi.commons.nodetype.QItemDefinitionsBuilder;
+import org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory;
 
 public class CompactNodeTypeDefTest extends TestCase {
 
@@ -43,7 +43,7 @@
         Reader reader = new InputStreamReader(getClass().getClassLoader().getResourceAsStream(TEST_FILE));
         CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping> cndReader =
             new CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping>(
-                reader, TEST_FILE, new QItemDefinitionsBuilder());
+                reader, TEST_FILE, new QDefinitionBuilderFactory());
 
         List<QNodeTypeDefinition> ntdList1 = cndReader.getNodeTypeDefinitions();
         NamespaceMapping nsm = cndReader.getNamespaceMapping();
@@ -55,7 +55,7 @@
 
         // Rerun the reader on the product of the writer
         cndReader = new CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping>(
-                new StringReader(sw.toString()), TEST_FILE, new QItemDefinitionsBuilder());
+                new StringReader(sw.toString()), TEST_FILE, new QDefinitionBuilderFactory());
 
         List<QNodeTypeDefinition> ntdList2 = cndReader.getNodeTypeDefinitions();
 



Mime
View raw message