You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by md...@apache.org on 2011/09/09 13:13:32 UTC
svn commit: r1167095 [1/2] - in
/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit:
./ commons/ commons/cnd/ commons/iterator/ commons/xml/ util/ value/
Author: mduerig
Date: Fri Sep 9 11:13:31 2011
New Revision: 1167095
URL: http://svn.apache.org/viewvc?rev=1167095&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
clean up
Modified:
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/JcrConstants.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractItem.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/Lexer.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/EventListenerIteratorAdapter.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/RangeIteratorAdapter.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/RangeIteratorDecorator.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/DefaultContentHandler.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/DocumentViewExporter.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/Exporter.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/SystemViewExporter.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/ToXmlContentHandler.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/XMLChar.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/AbstractValueFactory.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BinaryValue.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BooleanValue.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DecimalValue.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DoubleValue.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/LongValue.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ReferenceValue.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/StringValue.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/URIValue.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/JcrConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/JcrConstants.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/JcrConstants.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/JcrConstants.java Fri Sep 9 11:13:31 2011
@@ -29,283 +29,283 @@ public interface JcrConstants {
/**
* jcr:autoCreated
*/
- public static final String JCR_AUTOCREATED = "jcr:autoCreated";
+ String JCR_AUTOCREATED = "jcr:autoCreated";
/**
* jcr:baseVersion
*/
- public static final String JCR_BASEVERSION = "jcr:baseVersion";
+ String JCR_BASEVERSION = "jcr:baseVersion";
/**
* jcr:child
*/
- public static final String JCR_CHILD = "jcr:child";
+ String JCR_CHILD = "jcr:child";
/**
* jcr:childNodeDefinition
*/
- public static final String JCR_CHILDNODEDEFINITION = "jcr:childNodeDefinition";
+ String JCR_CHILDNODEDEFINITION = "jcr:childNodeDefinition";
/**
* jcr:content
*/
- public static final String JCR_CONTENT = "jcr:content";
+ String JCR_CONTENT = "jcr:content";
/**
* jcr:created
*/
- public static final String JCR_CREATED = "jcr:created";
+ String JCR_CREATED = "jcr:created";
/**
* jcr:data
*/
- public static final String JCR_DATA = "jcr:data";
+ String JCR_DATA = "jcr:data";
/**
* jcr:defaultPrimaryType
*/
- public static final String JCR_DEFAULTPRIMARYTYPE = "jcr:defaultPrimaryType";
+ String JCR_DEFAULTPRIMARYTYPE = "jcr:defaultPrimaryType";
/**
* jcr:defaultValues
*/
- public static final String JCR_DEFAULTVALUES = "jcr:defaultValues";
+ String JCR_DEFAULTVALUES = "jcr:defaultValues";
/**
* jcr:encoding
*/
- public static final String JCR_ENCODING = "jcr:encoding";
+ String JCR_ENCODING = "jcr:encoding";
/**
* jcr:frozenMixinTypes
*/
- public static final String JCR_FROZENMIXINTYPES = "jcr:frozenMixinTypes";
+ String JCR_FROZENMIXINTYPES = "jcr:frozenMixinTypes";
/**
* jcr:frozenNode
*/
- public static final String JCR_FROZENNODE = "jcr:frozenNode";
+ String JCR_FROZENNODE = "jcr:frozenNode";
/**
* jcr:frozenPrimaryType
*/
- public static final String JCR_FROZENPRIMARYTYPE = "jcr:frozenPrimaryType";
+ String JCR_FROZENPRIMARYTYPE = "jcr:frozenPrimaryType";
/**
* jcr:frozenUuid
*/
- public static final String JCR_FROZENUUID = "jcr:frozenUuid";
+ String JCR_FROZENUUID = "jcr:frozenUuid";
/**
* jcr:hasOrderableChildNodes
*/
- public static final String JCR_HASORDERABLECHILDNODES = "jcr:hasOrderableChildNodes";
+ String JCR_HASORDERABLECHILDNODES = "jcr:hasOrderableChildNodes";
/**
* jcr:isCheckedOut
*/
- public static final String JCR_ISCHECKEDOUT = "jcr:isCheckedOut";
+ String JCR_ISCHECKEDOUT = "jcr:isCheckedOut";
/**
* jcr:isMixin
*/
- public static final String JCR_ISMIXIN = "jcr:isMixin";
+ String JCR_ISMIXIN = "jcr:isMixin";
/**
* jcr:language
*/
- public static final String JCR_LANGUAGE = "jcr:language";
+ String JCR_LANGUAGE = "jcr:language";
/**
* jcr:lastModified
*/
- public static final String JCR_LASTMODIFIED = "jcr:lastModified";
+ String JCR_LASTMODIFIED = "jcr:lastModified";
/**
* jcr:lockIsDeep
*/
- public static final String JCR_LOCKISDEEP = "jcr:lockIsDeep";
+ String JCR_LOCKISDEEP = "jcr:lockIsDeep";
/**
* jcr:lockOwner
*/
- public static final String JCR_LOCKOWNER = "jcr:lockOwner";
+ String JCR_LOCKOWNER = "jcr:lockOwner";
/**
* jcr:mandatory
*/
- public static final String JCR_MANDATORY = "jcr:mandatory";
+ String JCR_MANDATORY = "jcr:mandatory";
/**
* jcr:mergeFailed
*/
- public static final String JCR_MERGEFAILED = "jcr:mergeFailed";
+ String JCR_MERGEFAILED = "jcr:mergeFailed";
/**
* jcr:mimeType
*/
- public static final String JCR_MIMETYPE = "jcr:mimeType";
+ String JCR_MIMETYPE = "jcr:mimeType";
/**
* jcr:mixinTypes
*/
- public static final String JCR_MIXINTYPES = "jcr:mixinTypes";
+ String JCR_MIXINTYPES = "jcr:mixinTypes";
/**
* jcr:multiple
*/
- public static final String JCR_MULTIPLE = "jcr:multiple";
+ String JCR_MULTIPLE = "jcr:multiple";
/**
* jcr:name
*/
- public static final String JCR_NAME = "jcr:name";
+ String JCR_NAME = "jcr:name";
/**
* jcr:nodeTypeName
*/
- public static final String JCR_NODETYPENAME = "jcr:nodeTypeName";
+ String JCR_NODETYPENAME = "jcr:nodeTypeName";
/**
* jcr:onParentVersion
*/
- public static final String JCR_ONPARENTVERSION = "jcr:onParentVersion";
+ String JCR_ONPARENTVERSION = "jcr:onParentVersion";
/**
* jcr:predecessors
*/
- public static final String JCR_PREDECESSORS = "jcr:predecessors";
+ String JCR_PREDECESSORS = "jcr:predecessors";
/**
* jcr:primaryItemName
*/
- public static final String JCR_PRIMARYITEMNAME = "jcr:primaryItemName";
+ String JCR_PRIMARYITEMNAME = "jcr:primaryItemName";
/**
* jcr:primaryType
*/
- public static final String JCR_PRIMARYTYPE = "jcr:primaryType";
+ String JCR_PRIMARYTYPE = "jcr:primaryType";
/**
* jcr:propertyDefinition
*/
- public static final String JCR_PROPERTYDEFINITION = "jcr:propertyDefinition";
+ String JCR_PROPERTYDEFINITION = "jcr:propertyDefinition";
/**
* jcr:protected
*/
- public static final String JCR_PROTECTED = "jcr:protected";
+ String JCR_PROTECTED = "jcr:protected";
/**
* jcr:requiredPrimaryTypes
*/
- public static final String JCR_REQUIREDPRIMARYTYPES = "jcr:requiredPrimaryTypes";
+ String JCR_REQUIREDPRIMARYTYPES = "jcr:requiredPrimaryTypes";
/**
* jcr:requiredType
*/
- public static final String JCR_REQUIREDTYPE = "jcr:requiredType";
+ String JCR_REQUIREDTYPE = "jcr:requiredType";
/**
* jcr:rootVersion
*/
- public static final String JCR_ROOTVERSION = "jcr:rootVersion";
+ String JCR_ROOTVERSION = "jcr:rootVersion";
/**
* jcr:sameNameSiblings
*/
- public static final String JCR_SAMENAMESIBLINGS = "jcr:sameNameSiblings";
+ String JCR_SAMENAMESIBLINGS = "jcr:sameNameSiblings";
/**
* jcr:statement
*/
- public static final String JCR_STATEMENT = "jcr:statement";
+ String JCR_STATEMENT = "jcr:statement";
/**
* jcr:successors
*/
- public static final String JCR_SUCCESSORS = "jcr:successors";
+ String JCR_SUCCESSORS = "jcr:successors";
/**
* jcr:supertypes
*/
- public static final String JCR_SUPERTYPES = "jcr:supertypes";
+ String JCR_SUPERTYPES = "jcr:supertypes";
/**
* jcr:system
*/
- public static final String JCR_SYSTEM = "jcr:system";
+ String JCR_SYSTEM = "jcr:system";
/**
* jcr:uuid
*/
- public static final String JCR_UUID = "jcr:uuid";
+ String JCR_UUID = "jcr:uuid";
/**
* jcr:valueConstraints
*/
- public static final String JCR_VALUECONSTRAINTS = "jcr:valueConstraints";
+ String JCR_VALUECONSTRAINTS = "jcr:valueConstraints";
/**
* jcr:versionHistory
*/
- public static final String JCR_VERSIONHISTORY = "jcr:versionHistory";
+ String JCR_VERSIONHISTORY = "jcr:versionHistory";
/**
* jcr:versionLabels
*/
- public static final String JCR_VERSIONLABELS = "jcr:versionLabels";
+ String JCR_VERSIONLABELS = "jcr:versionLabels";
/**
* jcr:versionStorage
*/
- public static final String JCR_VERSIONSTORAGE = "jcr:versionStorage";
+ String JCR_VERSIONSTORAGE = "jcr:versionStorage";
/**
* jcr:versionableUuid
*/
- public static final String JCR_VERSIONABLEUUID = "jcr:versionableUuid";
+ String JCR_VERSIONABLEUUID = "jcr:versionableUuid";
/**
* Pseudo property jcr:path used with query results
*/
- public static final String JCR_PATH = "jcr:path";
+ String JCR_PATH = "jcr:path";
/**
* Pseudo property jcr:score used with query results
*/
- public static final String JCR_SCORE = "jcr:score";
+ String JCR_SCORE = "jcr:score";
/**
* mix:lockable
*/
- public static final String MIX_LOCKABLE = "mix:lockable";
+ String MIX_LOCKABLE = "mix:lockable";
/**
* mix:referenceable
*/
- public static final String MIX_REFERENCEABLE = "mix:referenceable";
+ String MIX_REFERENCEABLE = "mix:referenceable";
/**
* mix:versionable
*/
- public static final String MIX_VERSIONABLE = "mix:versionable";
+ String MIX_VERSIONABLE = "mix:versionable";
/**
* mix:shareable
*/
- public static final String MIX_SHAREABLE = "mix:shareable";
+ String MIX_SHAREABLE = "mix:shareable";
/**
* nt:base
*/
- public static final String NT_BASE = "nt:base";
+ String NT_BASE = "nt:base";
/**
* nt:childNodeDefinition
*/
- public static final String NT_CHILDNODEDEFINITION = "nt:childNodeDefinition";
+ String NT_CHILDNODEDEFINITION = "nt:childNodeDefinition";
/**
* nt:file
*/
- public static final String NT_FILE = "nt:file";
+ String NT_FILE = "nt:file";
/**
* nt:folder
*/
- public static final String NT_FOLDER = "nt:folder";
+ String NT_FOLDER = "nt:folder";
/**
* nt:frozenNode
*/
- public static final String NT_FROZENNODE = "nt:frozenNode";
+ String NT_FROZENNODE = "nt:frozenNode";
/**
* nt:hierarchyNode
*/
- public static final String NT_HIERARCHYNODE = "nt:hierarchyNode";
+ String NT_HIERARCHYNODE = "nt:hierarchyNode";
/**
* nt:linkedFile
*/
- public static final String NT_LINKEDFILE = "nt:linkedFile";
+ String NT_LINKEDFILE = "nt:linkedFile";
/**
* nt:nodeType
*/
- public static final String NT_NODETYPE = "nt:nodeType";
+ String NT_NODETYPE = "nt:nodeType";
/**
* nt:propertyDefinition
*/
- public static final String NT_PROPERTYDEFINITION = "nt:propertyDefinition";
+ String NT_PROPERTYDEFINITION = "nt:propertyDefinition";
/**
* nt:query
*/
- public static final String NT_QUERY = "nt:query";
+ String NT_QUERY = "nt:query";
/**
* nt:resource
*/
- public static final String NT_RESOURCE = "nt:resource";
+ String NT_RESOURCE = "nt:resource";
/**
* nt:unstructured
*/
- public static final String NT_UNSTRUCTURED = "nt:unstructured";
+ String NT_UNSTRUCTURED = "nt:unstructured";
/**
* nt:version
*/
- public static final String NT_VERSION = "nt:version";
+ String NT_VERSION = "nt:version";
/**
* nt:versionHistory
*/
- public static final String NT_VERSIONHISTORY = "nt:versionHistory";
+ String NT_VERSIONHISTORY = "nt:versionHistory";
/**
* nt:versionLabels
*/
- public static final String NT_VERSIONLABELS = "nt:versionLabels";
+ String NT_VERSIONLABELS = "nt:versionLabels";
/**
* nt:versionedChild
*/
- public static final String NT_VERSIONEDCHILD = "nt:versionedChild";
+ String NT_VERSIONEDCHILD = "nt:versionedChild";
}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractItem.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractItem.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractItem.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractItem.java Fri Sep 9 11:13:31 2011
@@ -58,12 +58,10 @@ public abstract class AbstractItem imple
* @throws AccessDeniedException if access to the ancestor item is denied
* @throws RepositoryException if an error occurs
*/
- public Item getAncestor(int depth)
- throws ItemNotFoundException, AccessDeniedException,
- RepositoryException {
+ public Item getAncestor(int depth) throws RepositoryException {
if (depth < 0) {
throw new ItemNotFoundException(
- this + ": Invalid ancestor depth (" + depth + ")");
+ this + ": Invalid ancestor depth (" + depth + ')');
} else if (depth == 0) {
return getSession().getRootNode();
}
@@ -74,7 +72,7 @@ public abstract class AbstractItem imple
slash = path.indexOf('/', slash + 1);
if (slash == -1) {
throw new ItemNotFoundException(
- this + ": Invalid ancestor depth (" + depth + ")");
+ this + ": Invalid ancestor depth (" + depth + ')');
}
}
slash = path.indexOf('/', slash + 1);
@@ -86,7 +84,7 @@ public abstract class AbstractItem imple
return getSession().getItem(path.substring(0, slash));
} catch (ItemNotFoundException e) {
throw new AccessDeniedException(
- this + ": Ancestor access denied (" + depth + ")");
+ this + ": Ancestor access denied (" + depth + ')');
}
}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java Fri Sep 9 11:13:31 2011
@@ -16,15 +16,14 @@
*/
package org.apache.jackrabbit.commons;
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.jackrabbit.util.XMLChar;
import javax.jcr.NamespaceException;
import javax.jcr.NamespaceRegistry;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-
-import org.apache.jackrabbit.util.XMLChar;
+import java.util.HashMap;
+import java.util.Map;
/**
* Helper class for working with JCR namespaces.
@@ -34,17 +33,17 @@ import org.apache.jackrabbit.util.XMLCha
public class NamespaceHelper {
/**
- * The <code>jcr</code> namespace URI.
+ * The {@code jcr} namespace URI.
*/
public static final String JCR = "http://www.jcp.org/jcr/1.0";
/**
- * The <code>nt</code> namespace URI.
+ * The {@code nt} namespace URI.
*/
public static final String NT = "http://www.jcp.org/jcr/nt/1.0";
/**
- * The <code>mix</code> namespace URI.
+ * The {@code mix} namespace URI.
*/
public static final String MIX = "http://www.jcp.org/jcr/mix/1.0";
@@ -74,19 +73,19 @@ public class NamespaceHelper {
public Map<String, String> getNamespaces() throws RepositoryException {
Map<String, String> namespaces = new HashMap<String, String>();
String[] prefixes = session.getNamespacePrefixes();
- for (String prefixe : prefixes) {
- namespaces.put(prefixe, session.getNamespaceURI(prefixe));
+ for (String prefix : prefixes) {
+ namespaces.put(prefix, session.getNamespaceURI(prefix));
}
return namespaces;
}
/**
* Returns the prefix mapped to the given namespace URI in the current
- * session, or <code>null</code> if the namespace does not exist.
+ * session, or {@code null} if the namespace does not exist.
*
* @see Session#getNamespacePrefix(String)
* @param uri namespace URI
- * @return namespace prefix, or <code>null</code>
+ * @return namespace prefix, or {@code null}
* @throws RepositoryException if the namespace could not be retrieved
*/
public String getPrefix(String uri) throws RepositoryException {
@@ -99,11 +98,11 @@ public class NamespaceHelper {
/**
* Returns the namespace URI mapped to the given prefix in the current
- * session, or <code>null</code> if the namespace does not exist.
+ * session, or {@code null} if the namespace does not exist.
*
* @see Session#getNamespaceURI(String)
* @param prefix namespace prefix
- * @return namespace prefix, or <code>null</code>
+ * @return namespace prefix, or {@code null}
* @throws RepositoryException if the namespace could not be retrieved
*/
public String getURI(String prefix) throws RepositoryException {
@@ -125,17 +124,17 @@ public class NamespaceHelper {
* @throws RepositoryException if the namespace could not be retrieved
*/
public String getJcrName(String uri, String name)
- throws NamespaceException, RepositoryException {
+ throws RepositoryException {
if (uri != null && uri.length() > 0) {
- return session.getNamespacePrefix(uri) + ":" + name;
+ return session.getNamespacePrefix(uri) + ':' + name;
} else {
return name;
}
}
/**
- * Replaces the standard <code>jcr</code>, <code>nt</code>, or
- * <code>mix</code> prefix in the given name with the prefix
+ * Replaces the standard {@code jcr}, {@code nt}, or
+ * {@code mix} prefix in the given name with the prefix
* mapped to that namespace in the current session.
* <p>
* The purpose of this method is to make it easier to write
@@ -150,8 +149,7 @@ public class NamespaceHelper {
* @throws IllegalArgumentException if the prefix is unknown
* @throws RepositoryException if the namespace could not be retrieved
*/
- public String getJcrName(String name)
- throws IllegalArgumentException, RepositoryException {
+ public String getJcrName(String name) throws IllegalArgumentException, RepositoryException {
String standardPrefix;
String currentPrefix;
@@ -190,8 +188,7 @@ public class NamespaceHelper {
* @return namespace prefix in the current session
* @throws RepositoryException if the namespace could not be registered
*/
- public String registerNamespace(String prefix, String uri)
- throws RepositoryException {
+ public String registerNamespace(String prefix, String uri) throws RepositoryException {
NamespaceRegistry registry =
session.getWorkspace().getNamespaceRegistry();
try {
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/Lexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/Lexer.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/Lexer.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/Lexer.java Fri Sep 9 11:13:31 2011
@@ -127,9 +127,9 @@ public class Lexer {
private final String systemId;
/**
- * Creates an unitialized lexer on top of the given reader.
+ * Creates an uninitialized lexer on top of the given reader.
* @param r the reader
- * @param systemId informational systemid of the given stream
+ * @param systemId informational system id of the given stream
*/
public Lexer(Reader r, String systemId) {
this.systemId = systemId;
@@ -201,7 +201,7 @@ public class Lexer {
}
/**
- * Creates a failure exception including the current line number and systemid.
+ * Creates a failure exception including the current line number and system id.
* @param message message
* @throws ParseException the created exception
*/
@@ -210,7 +210,7 @@ public class Lexer {
}
/**
- * Creates a failure exception including the current line number and systemid.
+ * Creates a failure exception including the current line number and system id.
* @param message message
* @param e root cause
* @throws ParseException the created exception
@@ -220,7 +220,7 @@ public class Lexer {
}
/**
- * Creates a failure exception including the current line number and systemid.
+ * Creates a failure exception including the current line number and system id.
* @param e root cause
* @throws ParseException the created exception
*/
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/EventListenerIteratorAdapter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/EventListenerIteratorAdapter.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/EventListenerIteratorAdapter.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/EventListenerIteratorAdapter.java Fri Sep 9 11:13:31 2011
@@ -28,8 +28,7 @@ import java.util.NoSuchElementException;
* Adapter class for turning {@link RangeIterator}s or {@link Iterator}s
* into {@link EventListenerIterator}s.
*/
-public class EventListenerIteratorAdapter extends RangeIteratorDecorator
- implements EventListenerIterator {
+public class EventListenerIteratorAdapter extends RangeIteratorDecorator implements EventListenerIterator {
/**
* Static instance of an empty {@link EventListenerIterator}.
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/RangeIteratorAdapter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/RangeIteratorAdapter.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/RangeIteratorAdapter.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/RangeIteratorAdapter.java Fri Sep 9 11:13:31 2011
@@ -16,13 +16,12 @@
*/
package org.apache.jackrabbit.commons.iterator;
+import javax.jcr.RangeIterator;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.NoSuchElementException;
-import javax.jcr.RangeIterator;
-
/**
* Adapter for turning normal {@link Iterator}s into {@link RangeIterator}s.
* This helper class is used by the adapter classes in this package to
@@ -33,13 +32,12 @@ public class RangeIteratorAdapter implem
/**
* Static instance of an empty {@link RangeIterator}.
*/
- public static final RangeIterator EMPTY =
- new RangeIteratorAdapter(Collections.EMPTY_LIST);
+ public static final RangeIterator EMPTY = new RangeIteratorAdapter(Collections.emptyList());
/**
* The adapted iterator instance.
*/
- private final Iterator iterator;
+ private final Iterator<?> iterator;
/**
* Number of elements in the adapted iterator, or -1 if unknown.
@@ -57,10 +55,10 @@ public class RangeIteratorAdapter implem
* @param iterator adapted iterator
* @param size size of the iterator, or -1 if unknown
*/
- public RangeIteratorAdapter(Iterator iterator, long size) {
+ public RangeIteratorAdapter(Iterator<?> iterator, long size) {
this.iterator = iterator;
this.size = size;
- this.position = 0;
+ position = 0;
}
/**
@@ -68,7 +66,7 @@ public class RangeIteratorAdapter implem
*
* @param iterator adapted iterator
*/
- public RangeIteratorAdapter(Iterator iterator) {
+ public RangeIteratorAdapter(Iterator<?> iterator) {
this(iterator, -1);
}
@@ -77,7 +75,7 @@ public class RangeIteratorAdapter implem
*
* @param collection the collection to iterate
*/
- public RangeIteratorAdapter(Collection collection) {
+ public RangeIteratorAdapter(Collection<?> collection) {
this(collection.iterator(), collection.size());
}
@@ -108,10 +106,9 @@ public class RangeIteratorAdapter implem
* @throws IllegalArgumentException if n is negative
* @throws NoSuchElementException if skipped past the last element
*/
- public void skip(long n)
- throws IllegalArgumentException, NoSuchElementException {
+ public void skip(long n) throws IllegalArgumentException, NoSuchElementException {
if (n < 0) {
- throw new IllegalArgumentException("skip(" + n + ")");
+ throw new IllegalArgumentException("skip(" + n + ')');
}
for (long i = 0; i < n; i++) {
next();
@@ -125,8 +122,7 @@ public class RangeIteratorAdapter implem
* elements and the size of the iterator is unknown, then the size is
* set to the current position.
*
- * @return <code>true</code> if this iterator has more elements,
- * <code>false</code> otherwise
+ * @return {@code true} if this iterator has more elements, {@code false} otherwise
*/
public boolean hasNext() {
if (iterator.hasNext()) {
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/RangeIteratorDecorator.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/RangeIteratorDecorator.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/RangeIteratorDecorator.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/RangeIteratorDecorator.java Fri Sep 9 11:13:31 2011
@@ -16,14 +16,13 @@
*/
package org.apache.jackrabbit.commons.iterator;
-import java.util.NoSuchElementException;
-
import javax.jcr.RangeIterator;
+import java.util.NoSuchElementException;
/**
* Base class for decorating {@link RangeIterator}s.
*/
-public class RangeIteratorDecorator implements RangeIterator {
+public abstract class RangeIteratorDecorator implements RangeIterator {
/**
* The decorated iterator.
@@ -75,8 +74,7 @@ public class RangeIteratorDecorator impl
/**
* Delegated to the underlying iterator.
*
- * @return <code>true</code> if the iterator has more elements,
- * <code>false</code> otherwise
+ * @return {@code true} if the iterator has more elements, {@code false} otherwise
*/
public boolean hasNext() {
return iterator.hasNext();
@@ -98,8 +96,7 @@ public class RangeIteratorDecorator impl
* @throws UnsupportedOperationException if the operation is not supported
* @throws IllegalStateException if there is no element to be removed
*/
- public void remove()
- throws UnsupportedOperationException, IllegalStateException {
+ public void remove() throws UnsupportedOperationException, IllegalStateException {
iterator.remove();
}
}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/DefaultContentHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/DefaultContentHandler.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/DefaultContentHandler.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/DefaultContentHandler.java Fri Sep 9 11:13:31 2011
@@ -152,13 +152,13 @@ public class DefaultContentHandler exten
* @param namespaceURI passed through
* @param localName passed through
* @param qName passed through
- * @param atts passed through
+ * @param attributes passed through
* @throws SAXException if an error occurs
*/
- public void startElement(
- String namespaceURI, String localName, String qName,
- Attributes atts) throws SAXException {
- handler.startElement(namespaceURI, localName, qName, atts);
+ public void startElement(String namespaceURI, String localName, String qName, Attributes attributes)
+ throws SAXException {
+
+ handler.startElement(namespaceURI, localName, qName, attributes);
}
/**
@@ -168,8 +168,7 @@ public class DefaultContentHandler exten
* @param uri passed through
* @throws SAXException if an error occurs
*/
- public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
handler.startPrefixMapping(prefix, uri);
}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/DocumentViewExporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/DocumentViewExporter.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/DocumentViewExporter.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/DocumentViewExporter.java Fri Sep 9 11:13:31 2011
@@ -16,6 +16,12 @@
*/
package org.apache.jackrabbit.commons.xml;
+import org.apache.jackrabbit.commons.NamespaceHelper;
+import org.apache.jackrabbit.util.ISO9075;
+import org.apache.jackrabbit.value.ValueHelper;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
import javax.jcr.Property;
@@ -23,12 +29,6 @@ import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
-import org.apache.jackrabbit.commons.NamespaceHelper;
-import org.apache.jackrabbit.util.ISO9075;
-import org.apache.jackrabbit.value.ValueHelper;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
/**
* Document view exporter.
*
@@ -41,22 +41,19 @@ public class DocumentViewExporter extend
*
* @param session current session
* @param handler SAX event handler for the export
- * @param recurse whether to recursively export the whole subtree
+ * @param recurse whether to recursively export the whole sub tree
* @param binary whether to export binary values
*/
- public DocumentViewExporter(
- Session session, ContentHandler handler,
- boolean recurse, boolean binary) {
+ public DocumentViewExporter(Session session, ContentHandler handler, boolean recurse, boolean binary) {
super(session, handler, recurse, binary);
}
/**
* Exports the given node either as XML characters (if it's an
- * <code>xml:text</code> node) or as an XML element with properties
+ * {@code xml:text} node) or as an XML element with properties
* mapped to XML attributes.
*/
- protected void exportNode(String uri, String local, Node node)
- throws RepositoryException, SAXException {
+ protected void exportNode(String uri, String local, Node node) throws RepositoryException, SAXException {
if (NamespaceHelper.JCR.equals(uri) && "xmltext".equals(local)) {
try {
// assume jcr:xmlcharacters is single-valued
@@ -82,8 +79,7 @@ public class DocumentViewExporter extend
/**
* Maps the given single-valued property to an XML attribute.
*/
- protected void exportProperty(String uri, String local, Value value)
- throws RepositoryException {
+ protected void exportProperty(String uri, String local, Value value) throws RepositoryException {
// TODO: Serialized names and paths should use XML namespace mappings
String attribute = ValueHelper.serialize(value, false);
addAttribute(uri, ISO9075.encode(local), attribute);
@@ -96,10 +92,9 @@ public class DocumentViewExporter extend
* legal according to "6.4.2.5 Multi-value Properties" of the JSR 170
* specification.
*
- * @see https://issues.apache.org/jira/browse/JCR-325
+ * see https://issues.apache.org/jira/browse/JCR-325
*/
- protected void exportProperty(
- String uri, String local, int type, Value[] values) {
+ protected void exportProperty(String uri, String local, int type, Value[] values) {
// TODO: proper multi-value serialization support
}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/Exporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/Exporter.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/Exporter.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/Exporter.java Fri Sep 9 11:13:31 2011
@@ -16,14 +16,10 @@
*/
package org.apache.jackrabbit.commons.xml;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
+import org.apache.jackrabbit.commons.NamespaceHelper;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
@@ -34,11 +30,14 @@ import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
import javax.jcr.ValueFactory;
-
-import org.apache.jackrabbit.commons.NamespaceHelper;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
/**
* Abstract base class for document and system view exporters. This class
@@ -62,18 +61,18 @@ public abstract class Exporter {
/**
* Stack of namespace mappings.
*/
- private final LinkedList stack = new LinkedList();
+ private final LinkedList<Map<String, String>> stack = new LinkedList<Map<String, String>>();
/**
* The UUID strings of all shareable nodes already exported.
*/
- private final Set shareables = new HashSet();
+ private final Set<String> shareables = new HashSet<String>();
/**
* Whether the current node is a shareable node that has already been
* exported.
*/
- private boolean share = false;
+ private boolean share;
/**
* Current session.
@@ -91,7 +90,7 @@ public abstract class Exporter {
private final ContentHandler handler;
/**
- * Whether to export the subtree or just the given node.
+ * Whether to export the sub tree or just the given node.
*/
private final boolean recurse;
@@ -108,15 +107,13 @@ public abstract class Exporter {
* @param recurse whether the export should be recursive
* @param binary whether the export should include binary values
*/
- protected Exporter(
- Session session, ContentHandler handler,
- boolean recurse, boolean binary) {
+ protected Exporter(Session session, ContentHandler handler, boolean recurse, boolean binary) {
this.session = session;
- this.helper = new NamespaceHelper(session);
+ helper = new NamespaceHelper(session);
this.handler = handler;
this.recurse = recurse;
this.binary = binary;
- stack.add(new HashMap());
+ stack.add(new HashMap<String, String>());
}
/**
@@ -134,9 +131,9 @@ public abstract class Exporter {
handler.startDocument();
String[] prefixes = session.getNamespacePrefixes();
- for (int i = 0; i < prefixes.length; i++) {
- if (prefixes[i].length() > 0 && !prefixes[i].equals("xml") ) {
- addNamespace(prefixes[i], session.getNamespaceURI(prefixes[i]));
+ for (String prefix : prefixes) {
+ if (prefix.length() > 0 && !prefix.equals("xml")) {
+ addNamespace(prefix, session.getNamespaceURI(prefix));
}
}
@@ -146,7 +143,7 @@ public abstract class Exporter {
}
/**
- * Called to export the given node. The node name (or <code>jcr:root</code>
+ * Called to export the given node. The node name (or {@code jcr:root}
* if the node is the root node) is given as an explicit pair of the
* resolved namespace URI and local part of the name.
* <p>
@@ -163,8 +160,7 @@ public abstract class Exporter {
* @throws RepositoryException if a repository error occurs
* @throws SAXException if a SAX error occurs
*/
- protected abstract void exportNode(String uri, String local, Node node)
- throws RepositoryException, SAXException;
+ protected abstract void exportNode(String uri, String local, Node node) throws RepositoryException, SAXException;
/**
* Called by {@link #exportProperties(Node)} to process a single-valued
@@ -176,8 +172,7 @@ public abstract class Exporter {
* @throws RepositoryException if a repository error occurs
* @throws SAXException if a SAX error occurs
*/
- protected abstract void exportProperty(
- String uri, String local, Value value)
+ protected abstract void exportProperty(String uri, String local, Value value)
throws RepositoryException, SAXException;
/**
@@ -191,8 +186,7 @@ public abstract class Exporter {
* @throws RepositoryException if a repository error occurs
* @throws SAXException if a SAX error occurs
*/
- protected abstract void exportProperty(
- String uri, String local, int type, Value[] values)
+ protected abstract void exportProperty(String uri, String local, int type, Value[] values)
throws RepositoryException, SAXException;
/**
@@ -204,8 +198,7 @@ public abstract class Exporter {
* @throws RepositoryException if a repository error occurs
* @throws SAXException if a SAX error occurs
*/
- protected void exportNodes(Node node)
- throws RepositoryException, SAXException {
+ protected void exportNodes(Node node) throws RepositoryException, SAXException {
if (recurse && !share) {
NodeIterator iterator = node.getNodes();
while (iterator.hasNext()) {
@@ -222,23 +215,22 @@ public abstract class Exporter {
* each property depending on whether the property is single- or
* multivalued.
* <p>
- * The first properties to be processed are <code>jcr:primaryType</code>,
- * <code>jcr:mixinTypes</code>, and <code>jcr:uuid</code>, and then the
+ * The first properties to be processed are {@code jcr:primaryType},
+ * {@code jcr:mixinTypes}, and {@code jcr:uuid}, and then the
* remaining properties ordered by their names.
* <p>
* If the node is a shareable node that has already been encountered by
- * this event generator, then only a <code>jcr:primaryType</code> property
- * with the fixed value "nt:share" and the <code>jcr:uuid</code> property
+ * this event generator, then only a {@code jcr:primaryType} property
+ * with the fixed value "nt:share" and the {@code jcr:uuid} property
* of the shareable node are exported.
*
- * @see https://issues.apache.org/jira/browse/JCR-1084
+ * see https://issues.apache.org/jira/browse/JCR-1084
* @param node node
* @return properties as sorted map
* @throws RepositoryException if a repository error occurs
* @throws SAXException if a SAX error occurs
*/
- protected void exportProperties(Node node)
- throws RepositoryException, SAXException {
+ protected void exportProperties(Node node) throws RepositoryException, SAXException {
// if node is shareable and has already been serialized, change its
// type to nt:share and process only the properties jcr:primaryType
// and jcr:uuid (mix:shareable is referenceable, so jcr:uuid exists)
@@ -253,7 +245,7 @@ public abstract class Exporter {
factory.createValue(node.getUUID()));
} else {
// Standard behaviour: return all properties (sorted, see JCR-1084)
- SortedMap properties = getProperties(node);
+ SortedMap<String, Property> properties = getProperties(node);
// serialize jcr:primaryType, jcr:mixinTypes & jcr:uuid first:
exportProperty(properties, helper.getJcrName("jcr:primaryType"));
@@ -261,18 +253,15 @@ public abstract class Exporter {
exportProperty(properties, helper.getJcrName("jcr:uuid"));
// serialize remaining properties
- Iterator iterator = properties.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry) iterator.next();
- String name = (String) entry.getKey();
- exportProperty(name, (Property) entry.getValue());
+ for (Entry<String, Property> entry : properties.entrySet()) {
+ exportProperty(entry.getKey(), entry.getValue());
}
}
}
/**
* Utility method for exporting the given node. Parses the node name
- * (or <code>jcr:root</code> if given the root node) and calls
+ * (or {@code jcr:root} if given the root node) and calls
* {@link #exportNode(String, String, Node)} with the resolved namespace
* URI and the local part of the name.
*
@@ -280,8 +269,7 @@ public abstract class Exporter {
* @throws RepositoryException if a repository error occurs
* @throws SAXException if a SAX error occurs
*/
- private void exportNode(Node node)
- throws RepositoryException, SAXException {
+ private void exportNode(Node node) throws RepositoryException, SAXException {
share = node.isNodeType(helper.getJcrName("mix:shareable"))
&& !shareables.add(node.getUUID());
@@ -306,8 +294,8 @@ public abstract class Exporter {
* @return sorted map (keyed by name) of properties
* @throws RepositoryException if a repository error occurs
*/
- private SortedMap getProperties(Node node) throws RepositoryException {
- SortedMap properties = new TreeMap();
+ private static SortedMap<String, Property> getProperties(Node node) throws RepositoryException {
+ SortedMap<String, Property> properties = new TreeMap<String, Property>();
PropertyIterator iterator = node.getProperties();
while (iterator.hasNext()) {
Property property = iterator.nextProperty();
@@ -319,7 +307,7 @@ public abstract class Exporter {
/**
* Utility method for processing the named property from the given
* map of properties. If the property exists, it is removed from the
- * given map and passed to {@link #exportProperty(Property)}.
+ * given map and passed to {@link #exportProperty(String, Property)}.
* The property is ignored if it does not exist.
*
* @param properties map of properties
@@ -327,9 +315,8 @@ public abstract class Exporter {
* @throws RepositoryException if a repository error occurs
* @throws SAXException if a SAX error occurs
*/
- private void exportProperty(Map properties, String name)
- throws RepositoryException, SAXException {
- Property property = (Property) properties.remove(name);
+ private void exportProperty(Map<String, Property> properties, String name) throws RepositoryException, SAXException {
+ Property property = properties.remove(name);
if (property != null) {
exportProperty(name, property);
}
@@ -337,7 +324,8 @@ public abstract class Exporter {
/**
* Utility method for processing the given property. Calls either
- * {@link #exportProperty(Value)} or {@link #exportProperty(int, Value[])}
+ * {@link #exportProperty(String, String, int, Value[])} or
+ * {@link #exportProperty(String, String, Value)}
* depending on whether the the property is single- or multivalued.
*
* @param name property name
@@ -345,8 +333,7 @@ public abstract class Exporter {
* @throws RepositoryException if a repository error occurs
* @throws SAXException if a SAX error occurs
*/
- private void exportProperty(String name, Property property)
- throws RepositoryException, SAXException {
+ private void exportProperty(String name, Property property) throws RepositoryException, SAXException {
String uri = "";
String local = name;
int colon = name.indexOf(':');
@@ -383,8 +370,7 @@ public abstract class Exporter {
* @param length number of characters to emit
* @throws SAXException if a SAX error occurs
*/
- protected void characters(char[] ch, int start, int length)
- throws SAXException {
+ protected void characters(char[] ch, int start, int length) throws SAXException {
handler.characters(ch, start, length);
}
@@ -396,10 +382,8 @@ public abstract class Exporter {
* @param value attribute value
* @throws RepositoryException if a repository error occurs
*/
- protected void addAttribute(String uri, String local, String value)
- throws RepositoryException {
- attributes.addAttribute(
- uri, local, getXMLName(uri, local), "CDATA", value);
+ protected void addAttribute(String uri, String local, String value) throws RepositoryException {
+ attributes.addAttribute(uri, local, getXMLName(uri, local), "CDATA", value);
}
/**
@@ -414,19 +398,16 @@ public abstract class Exporter {
* @throws RepositoryException if a repository error occurs
* @throws SAXException if a SAX error occurs
*/
- protected void startElement(String uri, String local)
- throws SAXException, RepositoryException {
+ protected void startElement(String uri, String local) throws SAXException, RepositoryException {
// Prefixed name is generated before namespace handling so that a
// potential new prefix mapping gets included as a xmlns attribute
String name = getXMLName(uri, local);
// Add namespace mappings
- Map namespaces = (Map) stack.getFirst();
- Iterator iterator = namespaces.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry) iterator.next();
- String namespace = (String) entry.getKey();
- String prefix = (String) entry.getValue();
+ Map<String, String> namespaces = stack.getFirst();
+ for (Entry<String, String> entry : namespaces.entrySet()) {
+ String namespace = entry.getKey();
+ String prefix = entry.getValue();
handler.startPrefixMapping(prefix, namespace);
attributes.addAttribute(
"http://www.w3.org/2000/xmlns/", prefix, "xmlns:" + prefix,
@@ -436,7 +417,7 @@ public abstract class Exporter {
// Emit the start element event, and clear things for the next element
handler.startElement(uri, local, name, attributes);
attributes.clear();
- stack.addFirst(new HashMap());
+ stack.addFirst(new HashMap<String, String>());
}
/**
@@ -448,15 +429,13 @@ public abstract class Exporter {
* @throws RepositoryException if a repository error occurs
* @throws SAXException if a SAX error occurs
*/
- protected void endElement(String uri, String local)
- throws SAXException, RepositoryException {
+ protected void endElement(String uri, String local) throws SAXException, RepositoryException {
stack.removeFirst();
handler.endElement(uri, local, getXMLName(uri, local));
- Map namespaces = (Map) stack.getFirst();
- Iterator iterator = namespaces.values().iterator();
- while (iterator.hasNext()) {
- handler.endPrefixMapping((String) iterator.next());
+ Map<String, String> namespaces = stack.getFirst();
+ for (Object o : namespaces.values()) {
+ handler.endPrefixMapping((String) o);
}
namespaces.clear();
}
@@ -472,17 +451,16 @@ public abstract class Exporter {
* @return prefixed XML name
* @throws RepositoryException if a JCR namespace mapping is not available
*/
- protected String getXMLName(String uri, String local)
- throws RepositoryException {
+ protected String getXMLName(String uri, String local) throws RepositoryException {
if (uri.length() == 0) {
return local;
} else {
String prefix = getPrefix(uri);
if (prefix == null) {
prefix = getUniquePrefix(session.getNamespacePrefix(uri));
- ((Map) stack.getFirst()).put(uri, prefix);
+ stack.getFirst().put(uri, prefix);
}
- return prefix + ":" + local;
+ return prefix + ':' + local;
}
}
@@ -499,22 +477,21 @@ public abstract class Exporter {
String prefix = getPrefix(uri);
if (prefix == null) {
prefix = getUniquePrefix(hint);
- ((Map) stack.getFirst()).put(uri, prefix);
+ stack.getFirst().put(uri, prefix);
}
return prefix;
}
/**
* Returns the namespace prefix mapped to the given URI. Returns
- * <code>null</code> if the namespace URI is not registered.
+ * {@code null} if the namespace URI is not registered.
*
* @param uri namespace URI
- * @return prefix mapped to the URI, or <code>null</code>
+ * @return prefix mapped to the URI, or {@code null}
*/
private String getPrefix(String uri) {
- Iterator iterator = stack.iterator();
- while (iterator.hasNext()) {
- String prefix = (String) ((Map) iterator.next()).get(uri);
+ for (Map<String, String> elem : stack) {
+ String prefix = elem.get(uri);
if (prefix != null) {
return prefix;
}
@@ -545,13 +522,12 @@ public abstract class Exporter {
* current namespace stack.
*
* @param prefix namespace prefix
- * @return <code>true</code> if the prefix is mapped,
- * <code>false</code> otherwise
+ * @return {@code true} if the prefix is mapped,
+ * {@code false} otherwise
*/
private boolean prefixExists(String prefix) {
- Iterator iterator = stack.iterator();
- while (iterator.hasNext()) {
- if (((Map) iterator.next()).containsValue(prefix)) {
+ for (Map<String, String> elem : stack) {
+ if (elem.containsValue(prefix)) {
return true;
}
}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/SystemViewExporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/SystemViewExporter.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/SystemViewExporter.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/SystemViewExporter.java Fri Sep 9 11:13:31 2011
@@ -16,18 +16,17 @@
*/
package org.apache.jackrabbit.commons.xml;
-import java.io.IOException;
-import java.io.Writer;
+import org.apache.jackrabbit.value.ValueHelper;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
import javax.jcr.Node;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
-
-import org.apache.jackrabbit.value.ValueHelper;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
+import java.io.IOException;
+import java.io.Writer;
/**
* System view exporter.
@@ -37,41 +36,37 @@ import org.xml.sax.SAXException;
public class SystemViewExporter extends Exporter {
/**
- * The <code>sv</code> namespace URI.
+ * The {@code sv} namespace URI.
*/
private static final String SV = "http://www.jcp.org/jcr/sv/1.0";
/**
- * The <code>xs</code> namespace URI.
+ * The {@code xs} namespace URI.
*/
private static final String XS = "http://www.w3.org/2001/XMLSchema";
/**
- * The <code>xsi</code> namespace URI.
+ * The {@code xsi} namespace URI.
*/
- private static final String XSI =
- "http://www.w3.org/2001/XMLSchema-instance";
+ private static final String XSI = "http://www.w3.org/2001/XMLSchema-instance";
/**
* Creates a system view exporter.
*
* @param session current session
* @param handler SAX event handler for the export
- * @param recurse whether to recursively export the whole subtree
+ * @param recurse whether to recursively export the whole sub tree
* @param binary whether to export binary values
*/
- public SystemViewExporter(
- Session session, ContentHandler handler,
- boolean recurse, boolean binary) {
+ public SystemViewExporter(Session session, ContentHandler handler, boolean recurse, boolean binary) {
super(session, handler, recurse, binary);
addNamespace("sv", SV);
}
/**
- * Exports the given node as an <code>sv:node</code> element.
+ * Exports the given node as an {@code sv:node} element.
*/
- protected void exportNode(String uri, String local, Node node)
- throws RepositoryException, SAXException {
+ protected void exportNode(String uri, String local, Node node) throws RepositoryException, SAXException {
addAttribute(SV, "name", getXMLName(uri, local));
startElement(SV, "node");
exportProperties(node);
@@ -82,8 +77,7 @@ public class SystemViewExporter extends
/**
* Calls {@link #exportProperty(String, String, int, Value[])}.
*/
- protected void exportProperty(String uri, String local, Value value)
- throws RepositoryException, SAXException {
+ protected void exportProperty(String uri, String local, Value value) throws RepositoryException, SAXException {
// start property element
addAttribute(SV, "name", getXMLName(uri, local));
addAttribute(SV, "type", PropertyType.nameFromValue(value.getType()));
@@ -94,30 +88,29 @@ public class SystemViewExporter extends
}
/**
- * Exports the given property as an <code>sv:property</code> element.
+ * Exports the given property as an {@code sv:property} element.
*/
- protected void exportProperty(
- String uri, String local, int type, Value[] values)
+ protected void exportProperty(String uri, String local, int type, Value[] values)
throws RepositoryException, SAXException {
+
// start property element
addAttribute(SV, "name", getXMLName(uri, local));
addAttribute(SV, "type", PropertyType.nameFromValue(type));
addAttribute(SV, "multiple", Boolean.TRUE.toString());
startElement(SV, "property");
// values
- for (int i = 0; i < values.length; i++) {
- exportValue(values[i]);
+ for (Value value : values) {
+ exportValue(value);
}
endElement(SV, "property");
}
/**
- * Exports the given value as an <code>sv:value</code> element.
+ * Exports the given value as an {@code sv:value} element.
*
* @param value value to be exported
*/
- private void exportValue(Value value)
- throws RepositoryException, SAXException {
+ private void exportValue(Value value) throws RepositoryException, SAXException {
try {
boolean binary = mustSendBinary(value);
if (binary) {
@@ -127,10 +120,10 @@ public class SystemViewExporter extends
}
startElement(SV, "value");
ValueHelper.serialize(value, false, binary, new Writer() {
- public void write(char[] cbuf, int off, int len)
+ public void write(char[] buf, int off, int len)
throws IOException {
try {
- SystemViewExporter.this.characters(cbuf, off, len);
+ characters(buf, off, len);
} catch (Exception e) {
IOException exception = new IOException();
exception.initCause(e);
@@ -163,7 +156,7 @@ public class SystemViewExporter extends
* @return whether the value should be treated as a binary
* @throws RepositoryException if a repository error occurs
*/
- private boolean mustSendBinary(Value value) throws RepositoryException {
+ private static boolean mustSendBinary(Value value) throws RepositoryException {
if (value.getType() != PropertyType.BINARY) {
String string = value.getString();
for (int i = 0; i < string.length(); i++) {
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/ToXmlContentHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/ToXmlContentHandler.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/ToXmlContentHandler.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/ToXmlContentHandler.java Fri Sep 9 11:13:31 2011
@@ -16,6 +16,11 @@
*/
package org.apache.jackrabbit.commons.xml;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
@@ -23,11 +28,6 @@ import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
/**
* Simple XML serializer. This content handler serializes the received
* SAX events as XML to a given {@link Writer} or {@link OutputStream}.
@@ -63,7 +63,7 @@ public class ToXmlContentHandler extends
/**
* Flag variable that is used to track whether a start tag has had it's
- * closing ">" appended. Set to <code>true</code> by the
+ * closing ">" appended. Set to {@code true} by the
* {@link #startElement(String, String, String, Attributes)} method that
* <em>does not</em> output the closing ">". If this flag is still set
* when the {#link {@link #endElement(String, String, String)}} method
@@ -73,7 +73,7 @@ public class ToXmlContentHandler extends
*
* @see #closeStartTagIfOpen()
*/
- private boolean startTagIsOpen = false;
+ private boolean startTagIsOpen;
//--------------------------------------------------------< constructors >
@@ -85,10 +85,9 @@ public class ToXmlContentHandler extends
* @param encoding character encoding
* @throws UnsupportedEncodingException if the encoding is not supported
*/
- public ToXmlContentHandler(OutputStream stream, String encoding)
- throws UnsupportedEncodingException {
- this.writer = new OutputStreamWriter(stream, encoding);
- this.declaration = "version=\"1.0\" encoding=\"" + encoding + "\"";
+ public ToXmlContentHandler(OutputStream stream, String encoding) throws UnsupportedEncodingException {
+ writer = new OutputStreamWriter(stream, encoding);
+ declaration = "version=\"1.0\" encoding=\"" + encoding + '\"';
}
/**
@@ -99,8 +98,8 @@ public class ToXmlContentHandler extends
*/
public ToXmlContentHandler(OutputStream stream) {
try {
- this.writer = new OutputStreamWriter(stream, "UTF-8");
- this.declaration = "version=\"1.0\" encoding=\"UTF-8\"";
+ writer = new OutputStreamWriter(stream, "UTF-8");
+ declaration = "version=\"1.0\" encoding=\"UTF-8\"";
} catch (UnsupportedEncodingException e) {
// should never happen
throw new IllegalStateException("UTF-8 is not supported!");
@@ -115,7 +114,7 @@ public class ToXmlContentHandler extends
*/
public ToXmlContentHandler(Writer writer) {
this.writer = writer;
- this.declaration = "version=\"1.0\"";
+ declaration = "version=\"1.0\"";
}
/**
@@ -129,8 +128,7 @@ public class ToXmlContentHandler extends
//-------------------------------------------------------------< private >
- private void write(char[] ch, int start, int length, boolean attribute)
- throws SAXException {
+ private void write(char[] ch, int start, int length, boolean attribute) throws SAXException {
for (int i = start; i < start + length; i++) {
try {
if (ch[i] == '>') {
@@ -188,8 +186,7 @@ public class ToXmlContentHandler extends
/**
* Serializes a processing instruction.
*/
- public void processingInstruction(String target, String data)
- throws SAXException {
+ public void processingInstruction(String target, String data) throws SAXException {
closeStartTagIfOpen();
try {
writer.write("<?");
@@ -208,18 +205,18 @@ public class ToXmlContentHandler extends
/**
* Outputs the specified start tag with the given attributes.
*/
- public void startElement(
- String namespaceURI, String localName, String qName,
- Attributes atts) throws SAXException {
+ public void startElement(String namespaceURI, String localName, String qName, Attributes attributes)
+ throws SAXException {
+
closeStartTagIfOpen();
try {
writer.write("<");
writer.write(qName);
- for (int i = 0; i < atts.getLength(); i++) {
+ for (int i = 0; i < attributes.getLength(); i++) {
writer.write(" ");
- writer.write(atts.getQName(i));
+ writer.write(attributes.getQName(i));
writer.write("=\"");
- char[] ch = atts.getValue(i).toCharArray();
+ char[] ch = attributes.getValue(i).toCharArray();
write(ch, 0, ch.length, true);
writer.write("\"");
}
@@ -233,8 +230,7 @@ public class ToXmlContentHandler extends
/**
* Escapes and outputs the given characters.
*/
- public void characters(char[] ch, int start, int length)
- throws SAXException {
+ public void characters(char[] ch, int start, int length) throws SAXException {
closeStartTagIfOpen();
write(ch, start, length, false);
}
@@ -242,17 +238,14 @@ public class ToXmlContentHandler extends
/**
* Escapes and outputs the given characters.
*/
- public void ignorableWhitespace(char[] ch, int start, int length)
- throws SAXException {
+ public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
characters(ch, start, length);
}
/**
* Outputs the specified end tag.
*/
- public void endElement(
- String namespaceURI, String localName, String qName)
- throws SAXException {
+ public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
try {
if (startTagIsOpen) {
writer.write("/>");
@@ -273,8 +266,6 @@ public class ToXmlContentHandler extends
/**
* Returns the serialized XML document (assuming the default no-argument
* constructor was used).
- *
- * @param serialized XML document
*/
public String toString() {
return writer.toString();
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/XMLChar.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/XMLChar.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/XMLChar.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/XMLChar.java Fri Sep 9 11:13:31 2011
@@ -42,8 +42,6 @@ import java.util.Arrays;
* @author Arnaud Le Hors, IBM
* @author Michael Glavassevich, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
- *
- * @version $Id$
*/
public class XMLChar {
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/AbstractValueFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/AbstractValueFactory.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/AbstractValueFactory.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/AbstractValueFactory.java Fri Sep 9 11:13:31 2011
@@ -16,11 +16,6 @@
*/
package org.apache.jackrabbit.value;
-import java.io.InputStream;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.util.Calendar;
-
import javax.jcr.Binary;
import javax.jcr.Node;
import javax.jcr.PropertyType;
@@ -28,16 +23,20 @@ import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.ValueFactory;
import javax.jcr.ValueFormatException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.Calendar;
/**
- * This class implements the <code>ValueFactory</code> interface.
+ * This class implements the {@code ValueFactory} interface.
*
* @see javax.jcr.Session#getValueFactory()
*/
public abstract class AbstractValueFactory implements ValueFactory {
/**
- * Constructs a <code>ValueFactory</code> object.
+ * Constructs a {@code ValueFactory} object.
*/
protected AbstractValueFactory() {
}
@@ -47,7 +46,7 @@ public abstract class AbstractValueFacto
* Implementations must assert that the given value is a valid jcr path.
*
* @param pathValue
- * @throws javax.jcr.ValueFormatException If the given <code>pathValue</code>
+ * @throws javax.jcr.ValueFormatException If the given {@code pathValue}
* isn't a valid jcr path.
*/
protected abstract void checkPathFormat(String pathValue) throws ValueFormatException;
@@ -57,36 +56,25 @@ public abstract class AbstractValueFacto
* Implementations must assert that the given value is a valid jcr name.
*
* @param nameValue
- * @throws javax.jcr.ValueFormatException If the given <code>pathValue</code>
+ * @throws javax.jcr.ValueFormatException If the given {@code pathValue}
* isn't a valid jcr name.
*/
protected abstract void checkNameFormat(String nameValue) throws ValueFormatException;
//---------------------------------------------------------< ValueFactory >
- /**
- * {@inheritDoc}
- */
+
public Value createValue(boolean value) {
return new BooleanValue(value);
}
- /**
- * {@inheritDoc}
- */
public Value createValue(Calendar value) {
return new DateValue(value);
}
- /**
- * {@inheritDoc}
- */
public Value createValue(double value) {
return new DoubleValue(value);
}
- /**
- * {@inheritDoc}
- */
public Value createValue(InputStream value) {
try {
return new BinaryValue(value);
@@ -96,30 +84,18 @@ public abstract class AbstractValueFacto
}
}
- /**
- * {@inheritDoc}
- */
public Value createValue(long value) {
return new LongValue(value);
}
- /**
- * {@inheritDoc}
- */
public Value createValue(Node value) throws RepositoryException {
return createValue(value, false);
}
- /**
- * {@inheritDoc}
- */
public Value createValue(String value) {
return new StringValue(value);
}
- /**
- * {@inheritDoc}
- */
public Value createValue(String value, int type)
throws ValueFormatException {
Value val;
@@ -168,9 +144,6 @@ public abstract class AbstractValueFacto
return val;
}
- /**
- * {@inheritDoc}
- */
public Binary createBinary(InputStream stream) throws RepositoryException {
try {
return new BinaryImpl(stream);
@@ -182,23 +155,14 @@ public abstract class AbstractValueFacto
}
}
- /**
- * {@inheritDoc}
- */
public Value createValue(Binary value) {
return new BinaryValue(value);
}
- /**
- * {@inheritDoc}
- */
public Value createValue(BigDecimal value) {
return new DecimalValue(value);
}
- /**
- * {@inheritDoc}
- */
public Value createValue(Node node, boolean weak)
throws RepositoryException {
if (weak) {
@@ -208,4 +172,4 @@ public abstract class AbstractValueFacto
}
}
-}
\ No newline at end of file
+}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java Fri Sep 9 11:13:31 2011
@@ -31,10 +31,10 @@ import java.util.Calendar;
/**
* This class is the superclass of the type-specific
- * classes implementing the <code>Value</code> interfaces.
+ * classes implementing the {@code Value} interfaces.
*
* @see javax.jcr.Value
- * @see StringValue
+ * @see java.lang.StringValue
* @see LongValue
* @see DoubleValue
* @see DecimalValue
@@ -53,7 +53,7 @@ public abstract class BaseValue implemen
protected final int type;
- protected InputStream stream = null;
+ protected InputStream stream;
/**
* Package-private default constructor.
@@ -70,27 +70,19 @@ public abstract class BaseValue implemen
*
* @return the internal string representation
* @throws javax.jcr.ValueFormatException if the value can not be represented as a
- * <code>String</code> or if the value is
- * <code>null</code>.
+ * {@code String} or if the value is
+ * {@code null}.
* @throws javax.jcr.RepositoryException if another error occurs.
*/
- protected abstract String getInternalString()
- throws ValueFormatException, RepositoryException;
+ protected abstract String getInternalString() throws ValueFormatException, RepositoryException;
//----------------------------------------------------------------< Value >
- /**
- * {@inheritDoc}
- */
+
public int getType() {
return type;
}
- /**
- * {@inheritDoc}
- */
- public Calendar getDate()
- throws ValueFormatException, IllegalStateException,
- RepositoryException {
+ public Calendar getDate() throws IllegalStateException, RepositoryException {
Calendar cal = ISO8601.parse(getInternalString());
if (cal == null) {
throw new ValueFormatException("not a valid date format");
@@ -99,12 +91,7 @@ public abstract class BaseValue implemen
}
}
- /**
- * {@inheritDoc}
- */
- public long getLong()
- throws ValueFormatException, IllegalStateException,
- RepositoryException {
+ public long getLong() throws IllegalStateException, RepositoryException {
try {
return Long.parseLong(getInternalString());
} catch (NumberFormatException e) {
@@ -112,21 +99,11 @@ public abstract class BaseValue implemen
}
}
- /**
- * {@inheritDoc}
- */
- public boolean getBoolean()
- throws ValueFormatException, IllegalStateException,
- RepositoryException {
+ public boolean getBoolean() throws IllegalStateException, RepositoryException {
return Boolean.valueOf(getInternalString());
}
- /**
- * {@inheritDoc}
- */
- public double getDouble()
- throws ValueFormatException, IllegalStateException,
- RepositoryException {
+ public double getDouble() throws IllegalStateException, RepositoryException {
try {
return Double.parseDouble(getInternalString());
} catch (NumberFormatException e) {
@@ -134,12 +111,7 @@ public abstract class BaseValue implemen
}
}
- /**
- * {@inheritDoc}
- */
- public BigDecimal getDecimal()
- throws ValueFormatException, IllegalStateException,
- RepositoryException {
+ public BigDecimal getDecimal() throws IllegalStateException, RepositoryException {
try {
return new BigDecimal(getInternalString());
} catch (NumberFormatException e) {
@@ -147,9 +119,6 @@ public abstract class BaseValue implemen
}
}
- /**
- * {@inheritDoc}
- */
public InputStream getStream()
throws IllegalStateException, RepositoryException {
if (stream != null) {
@@ -166,12 +135,7 @@ public abstract class BaseValue implemen
}
}
- /**
- * {@inheritDoc}
- */
- public Binary getBinary()
- throws ValueFormatException, IllegalStateException,
- RepositoryException {
+ public Binary getBinary() throws IllegalStateException, RepositoryException {
try {
// convert via string
return new BinaryImpl(new ByteArrayInputStream(getInternalString().getBytes(DEFAULT_ENCODING)));
@@ -183,12 +147,7 @@ public abstract class BaseValue implemen
}
}
- /**
- * {@inheritDoc}
- */
- public String getString()
- throws ValueFormatException, IllegalStateException,
- RepositoryException {
+ public String getString() throws IllegalStateException, RepositoryException {
return getInternalString();
}
}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BinaryValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BinaryValue.java?rev=1167095&r1=1167094&r2=1167095&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BinaryValue.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BinaryValue.java Fri Sep 9 11:13:31 2011
@@ -16,30 +16,29 @@
*/
package org.apache.jackrabbit.value;
+import javax.jcr.Binary;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
-import javax.jcr.ValueFormatException;
-import javax.jcr.Binary;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
/**
- * A <code>BinaryValue</code> provides an implementation
- * of the <code>Value</code> interface representing a binary value.
+ * A {@code BinaryValue} provides an implementation
+ * of the {@code Value} interface representing a binary value.
*/
public class BinaryValue extends BaseValue {
public static final int TYPE = PropertyType.BINARY;
- private Binary bin = null;
- private String text = null;
+ private Binary bin;
+ private String text;
/**
- * Constructs a <code>BinaryValue</code> object based on a string.
+ * Constructs a {@code BinaryValue} object based on a string.
*
- * @param text the string this <code>BinaryValue</code> should represent
+ * @param text the string this {@code BinaryValue} should represent
*/
public BinaryValue(String text) {
super(TYPE);
@@ -47,9 +46,9 @@ public class BinaryValue extends BaseVal
}
/**
- * Constructs a <code>BinaryValue</code> object based on a <code>Binary</code>.
+ * Constructs a {@code BinaryValue} object based on a {@code Binary}.
*
- * @param bin the bytes this <code>BinaryValue</code> should represent
+ * @param bin the bytes this {@code BinaryValue} should represent
*/
public BinaryValue(Binary bin) {
super(TYPE);
@@ -57,9 +56,9 @@ public class BinaryValue extends BaseVal
}
/**
- * Constructs a <code>BinaryValue</code> object based on a stream.
+ * Constructs a {@code BinaryValue} object based on a stream.
*
- * @param stream the stream this <code>BinaryValue</code> should represent
+ * @param stream the stream this {@code BinaryValue} should represent
*/
public BinaryValue(InputStream stream) {
super(TYPE);
@@ -71,9 +70,9 @@ public class BinaryValue extends BaseVal
}
/**
- * Constructs a <code>BinaryValue</code> object based on a byte array.
+ * Constructs a {@code BinaryValue} object based on a byte array.
*
- * @param data the bytes this <code>BinaryValue</code> should represent
+ * @param data the bytes this {@code BinaryValue} should represent
*/
public BinaryValue(byte[] data) {
super(TYPE);
@@ -83,13 +82,13 @@ public class BinaryValue extends BaseVal
/**
* Indicates whether some other object is "equal to" this one.
* <p/>
- * The result is <code>true</code> if and only if the argument is not
- * <code>null</code> and is a <code>BinaryValue</code> object that
+ * The result is {@code true} if and only if the argument is not
+ * {@code null} and is a {@code BinaryValue} object that
* represents the same value as this object.
*
* @param obj the reference object with which to compare.
- * @return <code>true</code> if this object is the same as the obj
- * argument; <code>false</code> otherwise.
+ * @return {@code true} if this object is the same as the obj
+ * argument; {@code false} otherwise.
*/
public boolean equals(Object obj) {
if (this == obj) {
@@ -97,12 +96,8 @@ public class BinaryValue extends BaseVal
}
if (obj instanceof BinaryValue) {
BinaryValue other = (BinaryValue) obj;
- if (text == other.text && stream == other.stream
- && bin == other.bin) {
- return true;
- }
- return (text != null && text.equals(other.text))
- || (bin != null && bin.equals(other.bin));
+ return text == other.text && stream == other.stream && bin == other.bin
+ || text != null && text.equals(other.text) || bin != null && bin.equals(other.bin);
}
return false;
}
@@ -119,6 +114,7 @@ public class BinaryValue extends BaseVal
}
//------------------------------------------------------------< BaseValue >
+
/**
* Gets the string representation of this binary value.
*
@@ -127,8 +123,7 @@ public class BinaryValue extends BaseVal
* @throws javax.jcr.ValueFormatException
* @throws javax.jcr.RepositoryException if another error occurs
*/
- public String getInternalString()
- throws ValueFormatException, RepositoryException {
+ public String getInternalString() throws RepositoryException {
// build text value if necessary
if (text == null) {
try {
@@ -147,11 +142,8 @@ public class BinaryValue extends BaseVal
}
//----------------------------------------------------------------< Value >
- /**
- * {@inheritDoc}
- */
- public InputStream getStream()
- throws IllegalStateException, RepositoryException {
+
+ public InputStream getStream() throws IllegalStateException, RepositoryException {
if (stream == null) {
if (bin != null) {
stream = bin.getStream();
@@ -168,13 +160,7 @@ public class BinaryValue extends BaseVal
return stream;
}
- /**
- * {@inheritDoc}
- */
- public Binary getBinary()
- throws ValueFormatException, IllegalStateException,
- RepositoryException {
-
+ public Binary getBinary() throws IllegalStateException, RepositoryException {
if (bin == null) {
try {
bin = new BinaryImpl(new ByteArrayInputStream(text.getBytes(DEFAULT_ENCODING)));