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/07 14:00:20 UTC
svn commit: r1166138 [12/12] - in /jackrabbit/sandbox/jackrabbit-mk:
jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/
jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/batch/
jackrabbit-spi-commons/src/main/j...
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/SimpleNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/SimpleNode.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/SimpleNode.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/SimpleNode.java Wed Sep 7 12:00:14 2011
@@ -41,20 +41,25 @@ public class SimpleNode implements Node
return new SimpleNode(p, id);
}
+ @Override
public void jjtOpen() {
}
+ @Override
public void jjtClose() {
}
+ @Override
public void jjtSetParent(Node n) {
parent = n;
}
+ @Override
public Node jjtGetParent() {
return parent;
}
+ @Override
public void jjtAddChild(Node n, int i) {
if (children == null) {
children = new Node[i + 1];
@@ -66,17 +71,20 @@ public class SimpleNode implements Node
children[i] = n;
}
+ @Override
public Node jjtGetChild(int i) {
return children[i];
}
+ @Override
public int jjtGetNumChildren() {
- return (children == null) ? 0 : children.length;
+ return children == null ? 0 : children.length;
}
/**
* Accept the visitor. *
*/
+ @Override
public Object jjtAccept(XPathVisitor visitor, Object data) {
return visitor.visit(this, data);
}
@@ -86,8 +94,8 @@ public class SimpleNode implements Node
*/
public Object childrenAccept(XPathVisitor visitor, Object data) {
if (children != null) {
- for (int i = 0; i < children.length; ++i) {
- data = children[i].jjtAccept(visitor, data);
+ for (Node aChildren : children) {
+ data = aChildren.jjtAccept(visitor, data);
}
}
return data;
@@ -116,8 +124,8 @@ public class SimpleNode implements Node
printValue(ps);
ps.println();
if (children != null) {
- for (int i = 0; i < children.length; ++i) {
- SimpleNode n = (SimpleNode) children[i];
+ for (Node aChildren : children) {
+ SimpleNode n = (SimpleNode) aChildren;
if (n != null) {
n.dump(prefix + " ", ps);
}
@@ -136,7 +144,7 @@ public class SimpleNode implements Node
public void printValue(java.io.PrintStream ps) {
if (null != m_value) {
- ps.print(" " + m_value);
+ ps.print(' ' + m_value);
}
}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java Wed Sep 7 12:00:14 2011
@@ -235,7 +235,7 @@ public class XPathQueryBuilder implement
private static final Map parsers = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK);
/**
- * The root <code>QueryNode</code>
+ * The root {@code QueryNode}
*/
private final QueryRootNode root;
@@ -260,7 +260,7 @@ public class XPathQueryBuilder implement
private final QueryNodeFactory factory;
/**
- * Creates a new <code>XPathQueryBuilder</code> instance.
+ * Creates a new {@code XPathQueryBuilder} instance.
*
* @param statement the XPath statement.
* @param resolver the name resolver to use.
@@ -273,7 +273,7 @@ public class XPathQueryBuilder implement
throws InvalidQueryException {
this.resolver = resolver;
this.factory = factory;
- this.root = factory.createQueryRootNode();
+ root = factory.createQueryRootNode();
try {
// create an XQuery statement because we're actually using an
// XQuery parser.
@@ -301,7 +301,7 @@ public class XPathQueryBuilder implement
// also catch any other exception
throw new InvalidQueryException(t.getMessage() + " for statement: " + statement, t);
}
- if (exceptions.size() > 0) {
+ if (!exceptions.isEmpty()) {
// simply report the first one
Exception e = (Exception) exceptions.get(0);
if (e instanceof InvalidQueryException) {
@@ -315,13 +315,13 @@ public class XPathQueryBuilder implement
}
/**
- * Creates a <code>QueryNode</code> tree from a XPath statement using the
- * passed query node <code>factory</code>.
+ * Creates a {@code QueryNode} tree from a XPath statement using the
+ * passed query node {@code factory}.
*
* @param statement the XPath statement.
* @param resolver the name resolver to use.
* @param factory the query node factory.
- * @return the <code>QueryNode</code> tree for the XPath statement.
+ * @return the {@code QueryNode} tree for the XPath statement.
* @throws InvalidQueryException if the XPath statement is malformed.
*/
public static QueryRootNode createQuery(String statement,
@@ -335,7 +335,7 @@ public class XPathQueryBuilder implement
* Creates a String representation of the query node tree in XPath syntax.
*
* @param root the root of the query node tree.
- * @param resolver to resolve <code>Name</code>s.
+ * @param resolver to resolve {@code Name}s.
* @return a String representation of the query node tree.
* @throws InvalidQueryException if the query node tree cannot be converted
* into a String representation due to restrictions in XPath.
@@ -346,9 +346,9 @@ public class XPathQueryBuilder implement
}
/**
- * Returns the root node of the <code>QueryNode</code> tree.
+ * Returns the root node of the {@code QueryNode} tree.
*
- * @return the root node of the <code>QueryNode</code> tree.
+ * @return the root node of the {@code QueryNode} tree.
*/
QueryRootNode getRootNode() {
return root;
@@ -357,14 +357,15 @@ public class XPathQueryBuilder implement
//---------------------< XPathVisitor >-------------------------------------
/**
- * Implements the generic visit method for this <code>XPathVisitor</code>.
+ * Implements the generic visit method for this {@code XPathVisitor}.
*
* @param node the current node as created by the XPath parser.
- * @param data the current <code>QueryNode</code> created by this
- * <code>XPathVisitor</code>.
- * @return the current <code>QueryNode</code>. Can be different from
- * <code>data</code>.
+ * @param data the current {@code QueryNode} created by this
+ * {@code XPathVisitor}.
+ * @return the current {@code QueryNode}. Can be different from
+ * {@code data}.
*/
+ @Override
public Object visit(SimpleNode node, Object data) {
QueryNode queryNode = (QueryNode) data;
switch (node.getId()) {
@@ -383,7 +384,7 @@ public class XPathQueryBuilder implement
case JJTSTEPEXPR:
if (isAttributeAxis(node)) {
if (queryNode.getType() == QueryNode.TYPE_RELATION
- || (queryNode.getType() == QueryNode.TYPE_DEREF && ((DerefQueryNode) queryNode).getRefProperty() == null)
+ || queryNode.getType() == QueryNode.TYPE_DEREF && ((DerefQueryNode) queryNode).getRefProperty() == null
|| queryNode.getType() == QueryNode.TYPE_ORDER
|| queryNode.getType() == QueryNode.TYPE_PATH
|| queryNode.getType() == QueryNode.TYPE_TEXTSEARCH) {
@@ -570,8 +571,8 @@ public class XPathQueryBuilder implement
//----------------------< internal >----------------------------------------
/**
- * Applies {@link #tmpRelPath} to <code>node</code> and reset the path to
- * <code>null</code>.
+ * Applies {@link #tmpRelPath} to {@code node} and reset the path to
+ * {@code null}.
*
* @param node a relation query node.
*/
@@ -585,9 +586,9 @@ public class XPathQueryBuilder implement
}
/**
- * Returns {@link #tmpRelPath} or <code>null</code> if there is none set.
+ * Returns {@link #tmpRelPath} or {@code null} if there is none set.
* When this method returns {@link #tmpRelPath} will have been set
- * <code>null</code>.
+ * {@code null}.
*
* @return {@link #tmpRelPath}.
*/
@@ -605,12 +606,12 @@ public class XPathQueryBuilder implement
}
/**
- * Creates a <code>LocationStepQueryNode</code> at the current position
+ * Creates a {@code LocationStepQueryNode} at the current position
* in parent.
*
* @param node the current node in the xpath syntax tree.
- * @param parent the parent <code>PathQueryNode</code>.
- * @return the created <code>LocationStepQueryNode</code>.
+ * @param parent the parent {@code PathQueryNode}.
+ * @return the created {@code LocationStepQueryNode}.
*/
private LocationStepQueryNode createLocationStep(SimpleNode node, NAryQueryNode parent) {
LocationStepQueryNode queryNode = null;
@@ -625,8 +626,7 @@ public class XPathQueryBuilder implement
parent.addOperand(queryNode);
break;
}
- descendant = (c.getId() == JJTSLASHSLASH
- || c.getId() == JJTROOTDESCENDANTS);
+ descendant = (c.getId() == JJTSLASHSLASH || c.getId() == JJTROOTDESCENDANTS);
}
node.childrenAccept(this, queryNode);
@@ -690,10 +690,10 @@ public class XPathQueryBuilder implement
/**
* Creates a new {@link org.apache.jackrabbit.spi.commons.query.RelationQueryNode}
- * with <code>queryNode</code> as its parent node.
+ * with {@code queryNode} as its parent node.
*
* @param node a comparison expression node.
- * @param queryNode the current <code>QueryNode</code>.
+ * @param queryNode the current {@code QueryNode}.
*/
private void createExpression(SimpleNode node, NAryQueryNode queryNode) {
if (node.getId() != JJTCOMPARISONEXPR) {
@@ -738,6 +738,7 @@ public class XPathQueryBuilder implement
// check if string transformation is valid
try {
rqn.acceptOperands(new DefaultQueryNodeVisitor() {
+ @Override
public Object visit(PropertyFunctionQueryNode node, Object data) {
String functionName = node.getFunctionName();
if ((functionName.equals(PropertyFunctionQueryNode.LOWER_CASE)
@@ -770,7 +771,7 @@ public class XPathQueryBuilder implement
}
/**
- * Assigns a value to the <code>queryNode</code>.
+ * Assigns a value to the {@code queryNode}.
*
* @param node must be of type string, decimal, double or integer; otherwise
* an InvalidQueryException is added to {@link #exceptions}.
@@ -797,7 +798,7 @@ public class XPathQueryBuilder implement
}
/**
- * Creates a function based on <code>node</code>.
+ * Creates a function based on {@code node}.
*
* @param node the function node from the xpath tree.
* @param queryNode the current query node.
@@ -814,7 +815,7 @@ public class XPathQueryBuilder implement
if (queryNode instanceof NAryQueryNode) {
QueryNode not = factory.createNotQueryNode(queryNode);
((NAryQueryNode) queryNode).addOperand(not);
- // @todo is this needed?
+ // todo is this needed?
queryNode = not;
// traverse
if (node.jjtGetNumChildren() == 2) {
@@ -1124,8 +1125,7 @@ public class XPathQueryBuilder implement
if (c == node) {
break;
}
- descendant = (c.getId() == JJTSLASHSLASH
- || c.getId() == JJTROOTDESCENDANTS);
+ descendant = (c.getId() == JJTSLASHSLASH || c.getId() == JJTROOTDESCENDANTS);
}
}
derefNode.setIncludeDescendants(descendant);
@@ -1158,13 +1158,13 @@ public class XPathQueryBuilder implement
}
/**
- * Returns true if <code>node</code> has a child node which is the attribute
+ * Returns true if {@code node} has a child node which is the attribute
* axis.
*
* @param node a node with type {@link #JJTSTEPEXPR}.
- * @return <code>true</code> if this step expression uses the attribute axis.
+ * @return {@code true} if this step expression uses the attribute axis.
*/
- private boolean isAttributeAxis(SimpleNode node) {
+ private static boolean isAttributeAxis(SimpleNode node) {
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
if (((SimpleNode) node.jjtGetChild(i)).getId() == JJTAT) {
return true;
@@ -1174,7 +1174,7 @@ public class XPathQueryBuilder implement
}
/**
- * Returns <code>true</code> if the NodeTest <code>node</code> is an
+ * Returns {@code true} if the NodeTest {@code node} is an
* attribute name test.
* Example:
* <pre>
@@ -1185,32 +1185,29 @@ public class XPathQueryBuilder implement
* Name foo
* </pre>
* @param node a node with type {@link #JJTNAMETEST}.
- * @return <code>true</code> if the name test <code>node</code> is on the
+ * @return {@code true} if the name test {@code node} is on the
* attribute axis.
*/
- private boolean isAttributeNameTest(SimpleNode node) {
+ private static boolean isAttributeNameTest(SimpleNode node) {
SimpleNode stepExpr = (SimpleNode) node.jjtGetParent().jjtGetParent();
- if (stepExpr.getId() == JJTSTEPEXPR) {
- return ((SimpleNode) stepExpr.jjtGetChild(0)).getId() == JJTAT;
- }
- return false;
+ return stepExpr.getId() == JJTSTEPEXPR && ((SimpleNode) stepExpr.jjtGetChild(0)).getId() == JJTAT;
}
/**
- * Unescapes single or double quotes depending on how <code>literal</code>
+ * Unescapes single or double quotes depending on how {@code literal}
* is enclosed and strips enclosing quotes.
*
* </p>
* Examples:</br>
- * <code>"foo""bar"</code> -> <code>foo"bar</code></br>
- * <code>'foo''bar'</code> -> <code>foo'bar</code></br>
+ * {@code "foo""bar"} -> {@code foo"bar}</br>
+ * {@code 'foo''bar'} -> {@code foo'bar}</br>
* but:</br>
- * <code>'foo""bar'</code> -> <code>foo""bar</code>
+ * {@code 'foo""bar'} -> {@code foo""bar}
*
* @param literal the string literal to unescape
* @return the unescaped and stripped literal.
*/
- private String unescapeQuotes(String literal) {
+ private static String unescapeQuotes(String literal) {
String value = literal.substring(1, literal.length() - 1);
if (value.length() == 0) {
// empty string
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/StringCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/StringCache.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/StringCache.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/StringCache.java Wed Sep 7 12:00:14 2011
@@ -34,7 +34,7 @@ public class StringCache {
private static int nextPowerOf2(int x) {
long i = 1;
- while (i < x && i < (Integer.MAX_VALUE / 2)) {
+ while (i < x && i < Integer.MAX_VALUE / 2) {
i += i;
}
return (int) i;
@@ -44,7 +44,7 @@ public class StringCache {
String s = getProperty(name);
if (s != null) {
try {
- return Boolean.valueOf(s).booleanValue();
+ return Boolean.valueOf(s);
} catch (NumberFormatException e) {
// ignore
}
@@ -56,7 +56,7 @@ public class StringCache {
String s = getProperty(name);
if (s != null) {
try {
- return Integer.decode(s).intValue();
+ return Integer.decode(s);
} catch (NumberFormatException e) {
// ignore
}
@@ -114,7 +114,7 @@ public class StringCache {
int hash = s.hashCode();
String[] cache = getCache();
if (cache != null) {
- int index = hash & (OBJECT_CACHE_SIZE - 1);
+ int index = hash & OBJECT_CACHE_SIZE - 1;
String cached = cache[index];
if (cached != null) {
if (s.equals(cached)) {
@@ -146,7 +146,7 @@ public class StringCache {
}
int hash = s.hashCode();
String[] cache = getCache();
- int index = hash & (OBJECT_CACHE_SIZE - 1);
+ int index = hash & OBJECT_CACHE_SIZE - 1;
if (cache == null) {
return s;
}
@@ -158,7 +158,6 @@ public class StringCache {
}
// create a new object that is not shared
// (to avoid out of memory if it is a substring of a big String)
- // NOPMD
s = new String(s);
cache[index] = s;
return s;
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java Wed Sep 7 12:00:14 2011
@@ -36,7 +36,7 @@ import java.io.IOException;
import java.io.Serializable;
/**
- * <code>AbstractQValue</code>...
+ * {@code AbstractQValue}...
*/
public abstract class AbstractQValue implements QValue, Serializable {
@@ -46,12 +46,12 @@ public abstract class AbstractQValue imp
protected final int type;
/**
- * Create a new <code>AbstractQValue</code>.
+ * Create a new {@code AbstractQValue}.
*
* @param value The value.
* @param type The property type.
- * @throws IllegalArgumentException if the passed <code>value</code>
- * is <code>null</code>.
+ * @throws IllegalArgumentException if the passed {@code value}
+ * is {@code null}.
*/
protected AbstractQValue(Object value, int type) {
if (value == null) {
@@ -62,12 +62,12 @@ public abstract class AbstractQValue imp
}
/**
- * Create a new <code>AbstractQValue</code>.
+ * Create a new {@code AbstractQValue}.
*
* @param value
* @param type
- * @throws IllegalArgumentException if the passed <code>value</code>
- * is <code>null</code> or if the <code>type</code> is neither STRING nor
+ * @throws IllegalArgumentException if the passed {@code value}
+ * is {@code null} or if the {@code type} is neither STRING nor
* REFERENCE/WEAKREFERENCE.
*/
protected AbstractQValue(String value, int type) {
@@ -82,44 +82,44 @@ public abstract class AbstractQValue imp
}
/**
- * Create a new <code>AbstractQValue</code>.
+ * Create a new {@code AbstractQValue}.
*
* @param value
- * @throws IllegalArgumentException if the passed <code>value</code>
- * is <code>null</code>.
+ * @throws IllegalArgumentException if the passed {@code value}
+ * is {@code null}.
*/
protected AbstractQValue(Long value) {
this(value, PropertyType.LONG);
}
/**
- * Create a new <code>AbstractQValue</code>.
+ * Create a new {@code AbstractQValue}.
*
* @param value
- * @throws IllegalArgumentException if the passed <code>value</code>
- * is <code>null</code>.
+ * @throws IllegalArgumentException if the passed {@code value}
+ * is {@code null}.
*/
protected AbstractQValue(Double value) {
this(value, PropertyType.DOUBLE);
}
/**
- * Create a new <code>AbstractQValue</code>.
+ * Create a new {@code AbstractQValue}.
*
* @param value
- * @throws IllegalArgumentException if the passed <code>value</code>
- * is <code>null</code>.
+ * @throws IllegalArgumentException if the passed {@code value}
+ * is {@code null}.
*/
protected AbstractQValue(Boolean value) {
this(value, PropertyType.BOOLEAN);
}
/**
- * Create a new <code>AbstractQValue</code>.
+ * Create a new {@code AbstractQValue}.
*
* @param value
- * @throws IllegalArgumentException if the passed <code>value</code>
- * is <code>null</code>.
+ * @throws IllegalArgumentException if the passed {@code value}
+ * is {@code null}.
*/
protected AbstractQValue(Calendar value) {
val = ISO8601.format(value);
@@ -127,53 +127,55 @@ public abstract class AbstractQValue imp
}
/**
- * Create a new <code>AbstractQValue</code>.
+ * Create a new {@code AbstractQValue}.
*
* @param value
- * @throws IllegalArgumentException if the passed <code>value</code>
- * is <code>null</code>.
+ * @throws IllegalArgumentException if the passed {@code value}
+ * is {@code null}.
*/
protected AbstractQValue(Name value) {
this(value, PropertyType.NAME);
}
/**
- * Create a new <code>AbstractQValue</code>.
+ * Create a new {@code AbstractQValue}.
*
* @param value
- * @throws IllegalArgumentException if the passed <code>value</code>
- * is <code>null</code>.
+ * @throws IllegalArgumentException if the passed {@code value}
+ * is {@code null}.
*/
protected AbstractQValue(Path value) {
this(value, PropertyType.PATH);
}
/**
- * Create a new <code>AbstractQValue</code>.
+ * Create a new {@code AbstractQValue}.
*
* @param value
- * @throws IllegalArgumentException if the passed <code>value</code>
- * is <code>null</code>.
+ * @throws IllegalArgumentException if the passed {@code value}
+ * is {@code null}.
*/
protected AbstractQValue(BigDecimal value) {
this(value, PropertyType.DECIMAL);
}
/**
- * Create a new <code>AbstractQValue</code>.
+ * Create a new {@code AbstractQValue}.
*
* @param value
- * @throws IllegalArgumentException if the passed <code>value</code>
- * is <code>null</code>.
+ * @throws IllegalArgumentException if the passed {@code value}
+ * is {@code null}.
*/
protected AbstractQValue(URI value) {
this(value, PropertyType.URI);
}
//---------------------------------------------------------< QValue >---
+
/**
* @see QValue#getType()
*/
+ @Override
public int getType() {
return type;
}
@@ -181,6 +183,7 @@ public abstract class AbstractQValue imp
/**
* @see QValue#getLength()
*/
+ @Override
public long getLength() throws RepositoryException {
return getString().length();
}
@@ -188,6 +191,7 @@ public abstract class AbstractQValue imp
/**
* @see QValue#getName()
*/
+ @Override
public Name getName() throws RepositoryException {
if (type == PropertyType.NAME) {
return (Name) val;
@@ -203,6 +207,7 @@ public abstract class AbstractQValue imp
/**
* @see QValue#getCalendar()
*/
+ @Override
public Calendar getCalendar() throws RepositoryException {
if (type == PropertyType.DATE) {
return ISO8601.parse(getString());
@@ -231,6 +236,7 @@ public abstract class AbstractQValue imp
/**
* @see QValue#getDecimal()
*/
+ @Override
public BigDecimal getDecimal() throws RepositoryException {
if (type == PropertyType.DECIMAL) {
return (BigDecimal) val;
@@ -252,6 +258,7 @@ public abstract class AbstractQValue imp
/**
* @see QValue#getURI()
*/
+ @Override
public URI getURI() throws RepositoryException {
if (type == PropertyType.URI) {
return (URI) val;
@@ -267,6 +274,7 @@ public abstract class AbstractQValue imp
/**
* @see QValue#getDouble()
*/
+ @Override
public double getDouble() throws RepositoryException {
if (type == PropertyType.DOUBLE) {
return (Double) val;
@@ -288,6 +296,7 @@ public abstract class AbstractQValue imp
/**
* @see QValue#getLong()
*/
+ @Override
public long getLong() throws RepositoryException {
if (type == PropertyType.LONG) {
return (Long) val;
@@ -310,6 +319,7 @@ public abstract class AbstractQValue imp
* @throws RepositoryException
* @see QValue#getBoolean()
*/
+ @Override
public boolean getBoolean() throws RepositoryException {
if (type == PropertyType.BOOLEAN) {
return (Boolean) val;
@@ -321,6 +331,7 @@ public abstract class AbstractQValue imp
/**
* @see QValue#getPath()
*/
+ @Override
public Path getPath() throws RepositoryException {
if (type == PropertyType.PATH) {
return (Path) val;
@@ -336,6 +347,7 @@ public abstract class AbstractQValue imp
/**
* @see QValue#getPath()
*/
+ @Override
public String getString() throws RepositoryException {
if (type == PropertyType.BINARY) {
InputStream stream = getStream();
@@ -360,12 +372,15 @@ public abstract class AbstractQValue imp
*
* @see QValue#getBinary()
*/
+ @Override
public Binary getBinary() throws RepositoryException {
return new Binary() {
+ @Override
public InputStream getStream() throws RepositoryException {
return AbstractQValue.this.getStream();
}
+ @Override
public int read(byte[] b, long position) throws IOException, RepositoryException {
InputStream in = getStream();
try {
@@ -383,10 +398,12 @@ public abstract class AbstractQValue imp
}
}
+ @Override
public long getSize() throws RepositoryException {
return getLength();
}
+ @Override
public void dispose() {
}
};
@@ -395,6 +412,7 @@ public abstract class AbstractQValue imp
/**
* @see QValue#discard()
*/
+ @Override
public void discard() {
// nothing to do
}
@@ -428,10 +446,7 @@ public abstract class AbstractQValue imp
}
if (obj instanceof AbstractQValue) {
AbstractQValue other = (AbstractQValue) obj;
- if (type != other.type) {
- return false;
- }
- return val.equals(other.val);
+ return type == other.type && val.equals(other.val);
}
return false;
}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValueFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValueFactory.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValueFactory.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValueFactory.java Wed Sep 7 12:00:14 2011
@@ -16,30 +16,29 @@
*/
package org.apache.jackrabbit.spi.commons.value;
-import java.util.Calendar;
-import java.util.UUID;
-import java.math.BigDecimal;
-import java.net.URI;
-import java.io.UnsupportedEncodingException;
-
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.ValueFormatException;
-
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.spi.PathFactory;
import org.apache.jackrabbit.spi.QPropertyDefinition;
import org.apache.jackrabbit.spi.QValue;
import org.apache.jackrabbit.spi.QValueFactory;
-import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.spi.commons.name.NameConstants;
import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
import org.apache.jackrabbit.util.ISO8601;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.UUID;
+
/**
- * <code>AbstractQValueFactory</code>...
+ * {@code AbstractQValueFactory}...
*/
public abstract class AbstractQValueFactory implements QValueFactory {
@@ -53,9 +52,11 @@ public abstract class AbstractQValueFact
//------------------------------------------------------< QValueFactory >---
+
/**
* @see QValueFactory#computeAutoValues(org.apache.jackrabbit.spi.QPropertyDefinition)
*/
+ @Override
public QValue[] computeAutoValues(QPropertyDefinition propertyDefinition) throws RepositoryException {
Name declaringNT = propertyDefinition.getDeclaringNodeType();
Name name = propertyDefinition.getName();
@@ -73,6 +74,7 @@ public abstract class AbstractQValueFact
/**
* @see QValueFactory#create(String, int)
*/
+ @Override
public QValue create(String value, int type) throws RepositoryException {
if (value == null) {
throw new IllegalArgumentException("Cannot create QValue from null value.");
@@ -125,6 +127,7 @@ public abstract class AbstractQValueFact
/**
* @see QValueFactory#create(Calendar)
*/
+ @Override
public QValue create(Calendar value) throws RepositoryException {
if (value == null) {
throw new IllegalArgumentException("Cannot create QValue from null value.");
@@ -135,6 +138,7 @@ public abstract class AbstractQValueFact
/**
* @see QValueFactory#create(double)
*/
+ @Override
public QValue create(double value) throws RepositoryException {
return new DefaultQValue(value);
}
@@ -142,6 +146,7 @@ public abstract class AbstractQValueFact
/**
* @see QValueFactory#create(long)
*/
+ @Override
public QValue create(long value) throws RepositoryException {
return new DefaultQValue(value);
}
@@ -149,6 +154,7 @@ public abstract class AbstractQValueFact
/**
* @see QValueFactory#create(boolean)
*/
+ @Override
public QValue create(boolean value) throws RepositoryException {
if (value) {
return DefaultQValue.TRUE;
@@ -160,6 +166,7 @@ public abstract class AbstractQValueFact
/**
* @see QValueFactory#create(Name)
*/
+ @Override
public QValue create(Name value) throws RepositoryException {
if (value == null) {
throw new IllegalArgumentException("Cannot create QValue from null value.");
@@ -170,6 +177,7 @@ public abstract class AbstractQValueFact
/**
* @see QValueFactory#create(Path)
*/
+ @Override
public QValue create(Path value) throws RepositoryException {
if (value == null) {
throw new IllegalArgumentException("Cannot create QValue from null value.");
@@ -180,6 +188,7 @@ public abstract class AbstractQValueFact
/**
* @see QValueFactory#create(URI)
*/
+ @Override
public QValue create(URI value) throws RepositoryException {
if (value == null) {
throw new IllegalArgumentException("Cannot create QValue from null value.");
@@ -190,6 +199,7 @@ public abstract class AbstractQValueFact
/**
* @see QValueFactory#create(URI)
*/
+ @Override
public QValue create(BigDecimal value) throws RepositoryException {
if (value == null) {
throw new IllegalArgumentException("Cannot create QValue from null value.");
@@ -203,7 +213,7 @@ public abstract class AbstractQValueFact
* @param value the string value.
* @return a new QValue.
*/
- protected QValue createString(String value) {
+ protected static QValue createString(String value) {
return new DefaultQValue(value, PropertyType.STRING);
}
@@ -214,7 +224,7 @@ public abstract class AbstractQValueFact
* @param weak whether the reference is weak.
* @return a new QValue.
*/
- protected QValue createReference(String ref, boolean weak) {
+ protected static QValue createReference(String ref, boolean weak) {
if (weak) {
return new DefaultQValue(ref, PropertyType.WEAKREFERENCE);
} else {
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/DefaultQValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/DefaultQValue.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/DefaultQValue.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/DefaultQValue.java Wed Sep 7 12:00:14 2011
@@ -16,25 +16,23 @@
*/
package org.apache.jackrabbit.spi.commons.value;
-import java.io.Serializable;
-import java.io.InputStream;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.QValue;
+
+import javax.jcr.RepositoryException;
import java.io.ByteArrayInputStream;
+import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URI;
import java.util.Calendar;
-import javax.jcr.RepositoryException;
-
-import org.apache.jackrabbit.spi.QValue;
-import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.Path;
-
/**
- * <code>QValue</code> implementation for all valid <code>PropertyType</code>s
+ * {@code QValue} implementation for all valid {@code PropertyType}s
* except for BINARY.
*/
-public class DefaultQValue extends AbstractQValue implements Serializable {
+public class DefaultQValue extends AbstractQValue {
private static final long serialVersionUID = -3887529703765183611L;
@@ -82,6 +80,7 @@ public class DefaultQValue extends Abstr
/**
* @see QValue#getStream()
*/
+ @Override
public InputStream getStream() throws RepositoryException {
try {
// convert via string
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java Wed Sep 7 12:00:14 2011
@@ -38,7 +38,7 @@ import java.io.Serializable;
import java.util.Arrays;
/**
- * <code>QValueFactoryImpl</code>...
+ * {@code QValueFactoryImpl}...
*/
public class QValueFactoryImpl extends AbstractQValueFactory {
@@ -54,6 +54,7 @@ public class QValueFactoryImpl extends A
/**
* @see QValueFactory#create(byte[])
*/
+ @Override
public QValue create(byte[] value) {
if (value == null) {
throw new IllegalArgumentException("Cannot create QValue from null value.");
@@ -64,6 +65,7 @@ public class QValueFactoryImpl extends A
/**
* @see QValueFactory#create(InputStream)
*/
+ @Override
public QValue create(InputStream value) throws IOException {
if (value == null) {
throw new IllegalArgumentException("Cannot create QValue from null value.");
@@ -74,6 +76,7 @@ public class QValueFactoryImpl extends A
/**
* @see QValueFactory#create(File)
*/
+ @Override
public QValue create(File value) throws IOException {
if (value == null) {
throw new IllegalArgumentException("Cannot create QValue from null value.");
@@ -84,12 +87,12 @@ public class QValueFactoryImpl extends A
//--------------------------------------------------------< Inner Class >---
/**
- * <code>BinaryQValue</code> represents a binary <code>Value</code> which is
- * backed by a resource or byte[]. Unlike <code>BinaryValue</code> it has no
- * state, i.e. the <code>getStream()</code> method always returns a fresh
- * <code>InputStream</code> instance.
+ * {@code BinaryQValue} represents a binary {@code Value} which is
+ * backed by a resource or byte[]. Unlike {@code BinaryValue} it has no
+ * state, i.e. the {@code getStream()} method always returns a fresh
+ * {@code InputStream} instance.
*/
- private static class BinaryQValue extends AbstractQValue implements Serializable {
+ private static class BinaryQValue extends AbstractQValue {
/**
* A dummy value for calling the constructor of AbstractQValue
@@ -123,18 +126,18 @@ public class QValueFactoryImpl extends A
/**
* Buffer for small-sized data
*/
- private byte[] buffer = BinaryQValue.EMPTY_BYTE_ARRAY;
+ private byte[] buffer = EMPTY_BYTE_ARRAY;
/**
- * Creates a new <code>BinaryQValue</code> instance from an
- * <code>InputStream</code>. The contents of the stream is spooled
+ * Creates a new {@code BinaryQValue} instance from an
+ * {@code InputStream}. The contents of the stream is spooled
* to a temporary file or to a byte buffer if its size is smaller than
* {@link #MAX_BUFFER_SIZE}.
* <p/>
* The new instance represents a <i>temporary</i> value whose dynamically
* allocated resources will be freed explicitly on {@link #discard()}.
*
- * @param in stream to be represented as a <code>BinaryQValue</code> instance
+ * @param in stream to be represented as a {@code BinaryQValue} instance
* @throws IOException if an error occurs while reading from the stream or
* writing to the temporary file
*/
@@ -143,17 +146,17 @@ public class QValueFactoryImpl extends A
}
/**
- * Creates a new <code>BinaryQValue</code> instance from an
- * <code>InputStream</code>. The contents of the stream is spooled
+ * Creates a new {@code BinaryQValue} instance from an
+ * {@code InputStream}. The contents of the stream is spooled
* to a temporary file or to a byte buffer if its size is smaller than
* {@link #MAX_BUFFER_SIZE}.
* <p/>
- * The <code>temp</code> parameter governs whether dynamically allocated
+ * The {@code temp} parameter governs whether dynamically allocated
* resources will be freed explicitly on {@link #discard()}. Note that any
* dynamically allocated resources (temp file/buffer) will be freed
* implicitly once this instance has been gc'ed.
*
- * @param in stream to be represented as a <code>BinaryQValue</code> instance
+ * @param in stream to be represented as a {@code BinaryQValue} instance
* @param temp flag indicating whether this instance represents a
* <i>temporary</i> value whose resources can be explicitly freed
* on {@link #discard()}.
@@ -173,7 +176,7 @@ public class QValueFactoryImpl extends A
// spool to temp file
out.write(spoolBuffer, 0, read);
len += read;
- } else if (len + read > BinaryQValue.MAX_BUFFER_SIZE) {
+ } else if (len + read > MAX_BUFFER_SIZE) {
// threshold for keeping data in memory exceeded;
// create temp file and spool buffer contents
TransientFileFactory fileFactory = TransientFileFactory.getInstance();
@@ -206,10 +209,10 @@ public class QValueFactoryImpl extends A
}
/**
- * Creates a new <code>BinaryQValue</code> instance from a
- * <code>byte[]</code> array.
+ * Creates a new {@code BinaryQValue} instance from a
+ * {@code byte[]} array.
*
- * @param bytes byte array to be represented as a <code>BinaryQValue</code>
+ * @param bytes byte array to be represented as a {@code BinaryQValue}
* instance
*/
private BinaryQValue(byte[] bytes) {
@@ -221,9 +224,9 @@ public class QValueFactoryImpl extends A
}
/**
- * Creates a new <code>BinaryQValue</code> instance from a <code>File</code>.
+ * Creates a new {@code BinaryQValue} instance from a {@code File}.
*
- * @param file file to be represented as a <code>BinaryQValue</code> instance
+ * @param file file to be represented as a {@code BinaryQValue} instance
* @throws IOException if the file can not be read
*/
private BinaryQValue(File file) throws IOException {
@@ -245,9 +248,9 @@ public class QValueFactoryImpl extends A
//---------------------------------------------------------< QValue >---
/**
- * Returns the length of this <code>BinaryQValue</code>.
+ * Returns the length of this {@code BinaryQValue}.
*
- * @return The length, in bytes, of this <code>BinaryQValue</code>,
+ * @return The length, in bytes, of this {@code BinaryQValue},
* or -1L if the length can't be determined.
* @see QValue#getLength()
*/
@@ -269,6 +272,7 @@ public class QValueFactoryImpl extends A
/**
* @see QValue#getStream()
*/
+ @Override
public InputStream getStream() throws RepositoryException {
// always return a 'fresh' stream
if (file != null) {
@@ -302,7 +306,7 @@ public class QValueFactoryImpl extends A
/**
* Frees temporarily allocated resources such as temporary file, buffer, etc.
- * If this <code>BinaryQValue</code> is backed by a persistent resource
+ * If this {@code BinaryQValue} is backed by a persistent resource
* calling this method will have no effect.
* @see QValue#discard()
*/
@@ -324,13 +328,13 @@ public class QValueFactoryImpl extends A
//-----------------------------------------------< java.lang.Object >---
/**
- * Returns a string representation of this <code>BinaryQValue</code>
+ * Returns a string representation of this {@code BinaryQValue}
* instance. The string representation of a resource backed value is
* the path of the underlying resource. If this instance is backed by an
* in-memory buffer the generic object string representation of the byte
* array will be used instead.
*
- * @return A string representation of this <code>BinaryQValue</code> instance.
+ * @return A string representation of this {@code BinaryQValue} instance.
*/
@Override
public String toString() {
@@ -343,9 +347,6 @@ public class QValueFactoryImpl extends A
}
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -353,8 +354,8 @@ public class QValueFactoryImpl extends A
}
if (obj instanceof BinaryQValue) {
BinaryQValue other = (BinaryQValue) obj;
- return ((file == null ? other.file == null : file.equals(other.file))
- && Arrays.equals(buffer, other.buffer));
+ return (file == null ? other.file == null : file.equals(other.file))
+ && Arrays.equals(buffer, other.buffer);
}
return false;
}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java Wed Sep 7 12:00:14 2011
@@ -16,90 +16,92 @@
*/
package org.apache.jackrabbit.spi.commons.value;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.math.BigDecimal;
-import java.util.Calendar;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
import javax.jcr.Binary;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.ValueFormatException;
-
-import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
-import org.apache.jackrabbit.spi.QValue;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.util.Calendar;
/**
- * A <code>QValueValue</code> provides an implementation
- * of the <code>Value</code> interface representing an SPI
- * <code>QValue</code>.
+ * A {@code QValueValue} provides an implementation
+ * of the {@code Value} interface representing an SPI
+ * {@code QValue}.
*/
public final class QValueValue implements Value {
// wrapped QValue
- private final QValue qvalue;
+ private final QValue qValue;
// used for keeping track of input streams that have already been passed back
- private InputStream stream = null;
+ private InputStream stream;
// for converting the internal NAME/PATH format to JCR format
private final NamePathResolver resolver;
/**
- * Constructs a <code>QValueValue</code> object representing an SPI
+ * Constructs a {@code QValueValue} object representing an SPI
* <codeQValue</code>.
*
- * @param qvalue the QValue this <code>QValueValue</code> should represent
+ * @param qValue the QValue this {@code QValueValue} should represent
* @param resolver fore resolving namespace URIs to prefixes in NAME/PATH properties
*/
- public QValueValue(QValue qvalue, NamePathResolver resolver) {
- this.qvalue = qvalue;
+ public QValueValue(QValue qValue, NamePathResolver resolver) {
+ this.qValue = qValue;
this.resolver = resolver;
}
/**
- * Returns the embedded <code>QValue</code>.
+ * Returns the embedded {@code QValue}.
*
- * @return the embedded <code>QValue</code>
+ * @return the embedded {@code QValue}
*/
public QValue getQValue() {
- return qvalue;
+ return qValue;
}
//--------------------------------------------------------------< Value >---
+
/**
* @see javax.jcr.Value#getBoolean()
*/
+ @Override
public boolean getBoolean() throws RepositoryException {
if (getType() == PropertyType.STRING || getType() == PropertyType.BINARY || getType() == PropertyType.BOOLEAN) {
- return Boolean.valueOf(qvalue.getString());
+ return Boolean.valueOf(qValue.getString());
} else {
- throw new ValueFormatException("incompatible type " + PropertyType.nameFromValue(qvalue.getType()));
+ throw new ValueFormatException("incompatible type " + PropertyType.nameFromValue(qValue.getType()));
}
}
/**
* @see javax.jcr.Value#getDecimal()
*/
- public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException {
+ @Override
+ public BigDecimal getDecimal() throws IllegalStateException, RepositoryException {
switch (getType()) {
case PropertyType.DECIMAL:
case PropertyType.DOUBLE:
case PropertyType.LONG:
case PropertyType.DATE:
case PropertyType.STRING:
- return qvalue.getDecimal();
+ return qValue.getDecimal();
default:
- throw new ValueFormatException("incompatible type " + PropertyType.nameFromValue(qvalue.getType()));
+ throw new ValueFormatException("incompatible type " + PropertyType.nameFromValue(qValue.getType()));
}
}
/**
* @see javax.jcr.Value#getBinary()
*/
+ @Override
public Binary getBinary() throws RepositoryException {
// JCR-2511 Value#getBinary() and #getStream() return internal representation for type PATH and NAME
if (getType() == PropertyType.NAME || getType() == PropertyType.PATH) {
@@ -108,6 +110,7 @@ public final class QValueValue implement
try {
final byte[] value = getString().getBytes("UTF-8");
return new Binary() {
+ @Override
public int read(byte[] b, long position) {
if (position >= value.length) {
return -1;
@@ -118,12 +121,15 @@ public final class QValueValue implement
return n;
}
}
+ @Override
public InputStream getStream() {
return new ByteArrayInputStream(value);
}
+ @Override
public long getSize() {
return value.length;
}
+ @Override
public void dispose() {
}
};
@@ -131,34 +137,38 @@ public final class QValueValue implement
throw new RepositoryException("UTF-8 is not supported", ex);
}
} else {
- return qvalue.getBinary();
+ return qValue.getBinary();
}
}
/**
* @see javax.jcr.Value#getDate()
*/
+ @Override
public Calendar getDate() throws RepositoryException {
- return qvalue.getCalendar();
+ return qValue.getCalendar();
}
/**
* @see javax.jcr.Value#getDouble()
*/
+ @Override
public double getDouble() throws RepositoryException {
- return qvalue.getDouble();
+ return qValue.getDouble();
}
/**
* @see javax.jcr.Value#getLong()
*/
+ @Override
public long getLong() throws RepositoryException {
- return qvalue.getLong();
+ return qValue.getLong();
}
/**
* @see javax.jcr.Value#getStream()
*/
+ @Override
public InputStream getStream() throws IllegalStateException, RepositoryException {
if (stream == null) {
if (getType() == PropertyType.NAME || getType() == PropertyType.PATH) {
@@ -169,7 +179,7 @@ public final class QValueValue implement
throw new RepositoryException("UTF-8 is not supported", ex);
}
} else {
- stream = qvalue.getStream();
+ stream = qValue.getStream();
}
}
return stream;
@@ -178,23 +188,25 @@ public final class QValueValue implement
/**
* @see javax.jcr.Value#getString()
*/
+ @Override
public String getString() throws RepositoryException {
if (getType() == PropertyType.NAME) {
// qualified name value needs to be resolved
- return resolver.getJCRName(qvalue.getName());
+ return resolver.getJCRName(qValue.getName());
} else if (getType() == PropertyType.PATH) {
// qualified path value needs to be resolved
- return resolver.getJCRPath(qvalue.getPath());
+ return resolver.getJCRPath(qValue.getPath());
} else {
- return qvalue.getString();
+ return qValue.getString();
}
}
/**
* @see javax.jcr.Value#getType()
*/
+ @Override
public int getType() {
- return qvalue.getType();
+ return qValue.getType();
}
//-------------------------------------------------------------< Object >---
@@ -203,11 +215,7 @@ public final class QValueValue implement
*/
@Override
public boolean equals(Object obj) {
- if (obj instanceof QValueValue) {
- return qvalue.equals(((QValueValue) obj).qvalue);
- } else {
- return false;
- }
+ return obj instanceof QValueValue && qValue.equals(((QValueValue) obj).qValue);
}
/**
@@ -215,6 +223,6 @@ public final class QValueValue implement
*/
@Override
public int hashCode() {
- return qvalue.hashCode();
+ return qValue.hashCode();
}
}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java Wed Sep 7 12:00:14 2011
@@ -16,10 +16,15 @@
*/
package org.apache.jackrabbit.spi.commons.value;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.util.Calendar;
+import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
+import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.util.ISO8601;
import javax.jcr.Binary;
import javax.jcr.NamespaceException;
@@ -29,21 +34,15 @@ import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.ValueFactory;
import javax.jcr.ValueFormatException;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
-import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
-import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
-import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.Path;
-import org.apache.jackrabbit.spi.QValue;
-import org.apache.jackrabbit.spi.QValueFactory;
-import org.apache.jackrabbit.util.ISO8601;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.Calendar;
/**
- * This class implements the <code>ValueFactory</code> interface,
- * wrapping an existing SPI <code>QValueFactory</code> and a
- * <code>NamePathResolver</code>.
+ * This class implements the {@code ValueFactory} interface,
+ * wrapping an existing SPI {@code QValueFactory} and a
+ * {@code NamePathResolver}.
*
* @see ValueFactory
* @see QValueFactory
@@ -54,11 +53,11 @@ public class ValueFactoryQImpl implement
private final NamePathResolver resolver;
/**
- * Constructs a new <code>ValueFactoryQImpl</code> based
- * on an existing SPI <code>QValueFactory</code> and a
- * <code>NamePathResolver</code>.
- * @param qfactory wrapped <code>QValueFactory</code>
- * @param resolver wrapped <code>NamePathResolver</code>
+ * Constructs a new {@code ValueFactoryQImpl} based
+ * on an existing SPI {@code QValueFactory} and a
+ * {@code NamePathResolver}.
+ * @param qfactory wrapped {@code QValueFactory}
+ * @param resolver wrapped {@code NamePathResolver}
*/
public ValueFactoryQImpl(QValueFactory qfactory, NamePathResolver resolver) {
this.qfactory = qfactory;
@@ -66,20 +65,20 @@ public class ValueFactoryQImpl implement
}
/**
- * The <code>QValueFactory</code> that is wrapped by this <code>ValueFactory</code>
+ * The {@code QValueFactory} that is wrapped by this {@code ValueFactory}
* instance.
*
- * @return qfactory The <code>QValueFactory</code> wrapped by this instance.
+ * @return qfactory The {@code QValueFactory} wrapped by this instance.
*/
public QValueFactory getQValueFactory() {
return qfactory;
}
/**
- * Create a new <code>Value</code> based on an existing
- * <code>QValue</code>
- * @param qvalue existing <code>QValue</code>
- * @return a <code>Value</code> representing the <code>QValue</code>
+ * Create a new {@code Value} based on an existing
+ * {@code QValue}
+ * @param qvalue existing {@code QValue}
+ * @return a {@code Value} representing the {@code QValue}
*/
public Value createValue(QValue qvalue) {
return new QValueValue(qvalue, resolver);
@@ -87,9 +86,7 @@ public class ValueFactoryQImpl implement
//---------------------------------------------------------< ValueFactory >
- /**
- * {@inheritDoc}
- */
+ @Override
public Value createValue(String value) {
try {
QValue qvalue = qfactory.create(value, PropertyType.STRING);
@@ -99,9 +96,7 @@ public class ValueFactoryQImpl implement
}
}
- /**
- * {@inheritDoc}
- */
+ @Override
public Value createValue(long value) {
try {
QValue qvalue = qfactory.create(value);
@@ -111,9 +106,7 @@ public class ValueFactoryQImpl implement
}
}
- /**
- * {@inheritDoc}
- */
+ @Override
public Value createValue(double value) {
try {
QValue qvalue = qfactory.create(value);
@@ -123,9 +116,7 @@ public class ValueFactoryQImpl implement
}
}
- /**
- * {@inheritDoc}
- */
+ @Override
public Value createValue(boolean value) {
try {
QValue qvalue = qfactory.create(value);
@@ -135,9 +126,7 @@ public class ValueFactoryQImpl implement
}
}
- /**
- * {@inheritDoc}
- */
+ @Override
public Value createValue(Calendar value) {
try {
ISO8601.getYear(value);
@@ -148,9 +137,7 @@ public class ValueFactoryQImpl implement
}
}
- /**
- * {@inheritDoc}
- */
+ @Override
public Value createValue(InputStream value) {
try {
QValue qvalue = qfactory.create(value);
@@ -165,16 +152,12 @@ public class ValueFactoryQImpl implement
}
}
- /**
- * {@inheritDoc}
- */
+ @Override
public Value createValue(Node value) throws RepositoryException {
return createValue(value, false);
}
- /**
- * {@inheritDoc}
- */
+ @Override
public Value createValue(String value, int type) throws ValueFormatException {
try {
QValue qvalue;
@@ -203,6 +186,7 @@ public class ValueFactoryQImpl implement
}
}
+ @Override
public Binary createBinary(InputStream stream) throws RepositoryException {
// TODO review/optimize/refactor
try {
@@ -218,6 +202,7 @@ public class ValueFactoryQImpl implement
}
}
+ @Override
public Value createValue(Binary value) {
// TODO review/optimize/refactor
try {
@@ -227,6 +212,7 @@ public class ValueFactoryQImpl implement
}
}
+ @Override
public Value createValue(BigDecimal value) {
try {
QValue qvalue = qfactory.create(value);
@@ -236,6 +222,7 @@ public class ValueFactoryQImpl implement
}
}
+ @Override
public Value createValue(Node value, boolean weak) throws RepositoryException {
QValue qvalue = qfactory.create(value.getUUID(), weak ? PropertyType.WEAKREFERENCE : PropertyType.REFERENCE);
return new QValueValue(qvalue, resolver);
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFormat.java Wed Sep 7 12:00:14 2011
@@ -31,9 +31,12 @@ import java.util.List;
import java.util.ArrayList;
/**
- * <code>ValueFormat</code>...
+ * {@code ValueFormat}...
*/
-public class ValueFormat {
+public final class ValueFormat {
+
+ private ValueFormat() {
+ }
/**
*
@@ -139,7 +142,7 @@ public class ValueFormat {
* @param value
* @param resolver
* @param factory
- * @return the JCR value created from the given <code>QValue</code>.
+ * @return the JCR value created from the given {@code QValue}.
* @throws RepositoryException
*/
public static Value getJCRValue(QValue value,
@@ -191,14 +194,14 @@ public class ValueFormat {
}
/**
- * Returns the JCR string representation of the given <code>QValue</code>.
+ * Returns the JCR string representation of the given {@code QValue}.
* This method is a shortcut for
* {@link #getJCRValue(QValue, NamePathResolver, ValueFactory)} followed by
* {@link Value#getString()}.
*
* @param value
* @param resolver
- * @return the JCR String representation for the given <code>QValue</code>.
+ * @return the JCR String representation for the given {@code QValue}.
* @throws RepositoryException
*/
public static String getJCRString(QValue value,
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/ItemInfoCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/ItemInfoCache.java?rev=1166138&r1=1166137&r2=1166138&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/ItemInfoCache.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/ItemInfoCache.java Wed Sep 7 12:00:14 2011
@@ -70,8 +70,8 @@ public interface ItemInfoCache {
return true;
}
- if (that instanceof ItemInfoCache.Entry) {
- ItemInfoCache.Entry other = (ItemInfoCache.Entry) that;
+ if (that instanceof ItemInfoCache.Entry<?>) {
+ ItemInfoCache.Entry<?> other = (ItemInfoCache.Entry<?>) that;
return generation == other.generation && info.equals(other.info);
}