[dna-commits] DNA SVN: r775 - trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic.
dna-commits at lists.jboss.org
dna-commits at lists.jboss.org
Thu Mar 12 16:40:20 EDT 2009
Author: rhauch
Date: 2009-03-12 16:40:20 -0400 (Thu, 12 Mar 2009)
New Revision: 775
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/NameValueFactory.java
Log:
DNA-194 Implement update JCR capability
Small optimization in the NameValueFactory that maintains a single static/shared instance for Name objects that have no namespace URI and a local name of "*". These are use pretty prevelently in the JCR type manager to represent residual child and property definitions.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/NameValueFactory.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/NameValueFactory.java 2009-03-12 20:14:20 UTC (rev 774)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/NameValueFactory.java 2009-03-12 20:40:20 UTC (rev 775)
@@ -66,6 +66,9 @@
private static final String PREFIXED_NAME_PATTERN_STRING = "(([^:/]*):)?(.*)";
private static final Pattern PREFIXED_NAME_PATTERN = Pattern.compile(PREFIXED_NAME_PATTERN_STRING);
+ private static Name BLANK_NAME;
+ private static Name ANY_NAME;
+
private final NamespaceRegistry namespaceRegistry;
public NameValueFactory( NamespaceRegistry namespaceRegistry,
@@ -92,9 +95,15 @@
if (decoder == null) decoder = getDecoder();
try {
if (value.length() == 0) {
- return new BasicName("", "");
+ if (BLANK_NAME == null) BLANK_NAME = new BasicName("", "");
+ return BLANK_NAME;
}
- if (value.charAt(0) != '{') {
+ char firstChar = value.charAt(0);
+ if (value.length() == 1 && firstChar == '*') {
+ if (ANY_NAME == null) ANY_NAME = new BasicName("", "*");
+ return ANY_NAME;
+ }
+ if (firstChar != '{') {
// First, see whether the value fits the prefixed name pattern ...
Matcher matcher = PREFIXED_NAME_PATTERN.matcher(value);
if (matcher.matches()) {
More information about the dna-commits
mailing list