Skip to content

Commit

Permalink
JCR-1232: Merge UUID to NodeId
Browse files Browse the repository at this point in the history
Use NodeId.toString() instead of NodeId.getUUID().toString(). The functionality is the same, and the former avoids and extra method call and reduces the getUUID() footprint.

git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/trunk@792464 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
jukka committed Jul 9, 2009
1 parent cb1256b commit c034838
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ public NodeId clone(NodeState srcState, NodeState destParentState, Name destName
NodeId destParentId = destParentState.getNodeId();
if (destParentId.equals(srcId) || hierMgr.isAncestor(srcId, destParentId)) {
String msg =
"Cloning Node with id " + srcId.getUUID()
+ " to parent with id " + destParentId.getUUID()
"Cloning Node with id " + srcId
+ " to parent with id " + destParentId
+ " would create a share cycle.";
log.debug(msg);
throw new RepositoryException(msg);
Expand All @@ -299,7 +299,7 @@ public NodeId clone(NodeState srcState, NodeState destParentState, Name destName
if (!srcState.addShare(destParentState.getNodeId())) {
String msg =
"Adding a shareable node with id ("
+ destParentState.getNodeId().getUUID()
+ destParentState.getNodeId()
+ ") twice to the same parent is not supported.";
log.debug(msg);
throw new UnsupportedRepositoryOperationException(msg);
Expand Down Expand Up @@ -1530,7 +1530,7 @@ private InternalValue[] computeSystemGeneratedPropertyValues(NodeState parent,
if (NameConstants.JCR_UUID.equals(name)) {
// jcr:uuid property
genValues = new InternalValue[]{InternalValue.create(
parent.getNodeId().getUUID().toString())};
parent.getNodeId().toString())};
}
} else if (NameConstants.NT_BASE.equals(declaringNT)) {
// nt:base node type
Expand Down Expand Up @@ -1927,7 +1927,7 @@ private PropertyState copyPropertyState(PropertyState srcState,
if (def.getDeclaringNodeType().equals(NameConstants.MIX_REFERENCEABLE)
&& propName.equals(NameConstants.JCR_UUID)) {
// set correct value of jcr:uuid property
newState.setValues(new InternalValue[]{InternalValue.create(parentId.getUUID().toString())});
newState.setValues(new InternalValue[]{InternalValue.create(parentId.toString())});
} else {
InternalValue[] newValues = new InternalValue[values.length];
for (int i = 0; i < values.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ protected InternalValue[] computeSystemGeneratedPropertyValues(Name name,
if (name.equals(NameConstants.JCR_UUID)) {
// jcr:uuid property
genValues = new InternalValue[]{
InternalValue.create(thisState.getNodeId().getUUID().toString())
InternalValue.create(thisState.getNodeId().toString())
};
}
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public boolean equals(Object obj) {
return true;
}
if (obj instanceof NodeReferencesId) {
return targetId.getUUID().equals(((NodeReferencesId) obj).targetId.getUUID());
return targetId.equals(((NodeReferencesId) obj).targetId);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected StringBuffer buildNodeFolderPath(StringBuffer buf, NodeId id) {
if (buf == null) {
buf = new StringBuffer();
}
char[] chars = id.getUUID().toString().toCharArray();
char[] chars = id.toString().toCharArray();
int cnt = 0;
for (int i = 0; i < chars.length; i++) {
if (chars[i] == '-') {
Expand Down Expand Up @@ -469,7 +469,7 @@ public synchronized PropertyState load(PropertyId id)
state.setType(PropertyType.STRING);
state.setDefinitionId(idJcrUUID);
state.setMultiValued(false);
state.setValues(new InternalValue[]{InternalValue.create(id.getParentId().getUUID().toString())});
state.setValues(new InternalValue[]{InternalValue.create(id.getParentId().toString())});
} else if (id.getName().equals(NameConstants.JCR_PRIMARYTYPE)) {
state = createNew(id);
state.setType(PropertyType.NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public ObjectPersistenceManager() {

private static String buildNodeFolderPath(NodeId id) {
StringBuffer sb = new StringBuffer();
char[] chars = id.getUUID().toString().toCharArray();
char[] chars = id.toString().toCharArray();
int cnt = 0;
for (int i = 0; i < chars.length; i++) {
if (chars[i] == '-') {
Expand Down Expand Up @@ -205,7 +205,7 @@ public synchronized NodeState load(NodeId id)
Serializer.deserialize(state, in);
return state;
} catch (Exception e) {
String msg = "failed to read node state: " + id.getUUID();
String msg = "failed to read node state: " + id;
log.debug(msg);
throw new ItemStateException(msg, e);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public String createId(PropertyId id, int index) {
// the blobId is an absolute file system path
StringBuffer sb = new StringBuffer();
sb.append(FileSystem.SEPARATOR_CHAR);
char[] chars = id.getParentId().getUUID().toString().toCharArray();
char[] chars = id.getParentId().toString().toCharArray();
int cnt = 0;
for (int i = 0; i < chars.length; i++) {
if (chars[i] == '-') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void setNodePathTemplate(String template) {
*/
private String buildNodeFolderPath(NodeId id) {
StringBuffer sb = new StringBuffer();
char[] chars = id.getUUID().toString().toCharArray();
char[] chars = id.toString().toCharArray();
int cnt = 0;
for (int i = 0; i < nodePathTemplate.length(); i++) {
char ch = nodePathTemplate.charAt(i);
Expand Down Expand Up @@ -224,7 +224,7 @@ private void readState(DOMWalker walker, NodeState state)
throw new ItemStateException(msg);
}
// check uuid
if (!state.getNodeId().getUUID().toString().equals(walker.getAttribute(UUID_ATTRIBUTE))) {
if (!state.getNodeId().toString().equals(walker.getAttribute(UUID_ATTRIBUTE))) {
String msg = "invalid serialized state: uuid mismatch";
log.debug(msg);
throw new ItemStateException(msg);
Expand Down Expand Up @@ -563,13 +563,13 @@ protected void store(NodeState state) throws ItemStateException {
writer = new BufferedWriter(osw);
}

String parentId = (state.getParentId() == null) ? "" : state.getParentId().getUUID().toString();
String parentId = (state.getParentId() == null) ? "" : state.getParentId().toString();
String encodedNodeType = Text.encodeIllegalXMLCharacters(state.getNodeTypeName().toString());
writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
writer.write("<" + NODE_ELEMENT + " "
+ UUID_ATTRIBUTE + "=\"" + id.getUUID() + "\" "
+ UUID_ATTRIBUTE + "=\"" + id + "\" "
+ PARENTUUID_ATTRIBUTE + "=\"" + parentId + "\" "
+ DEFINITIONID_ATTRIBUTE + "=\"" + state.getDefinitionId().toString() + "\" "
+ DEFINITIONID_ATTRIBUTE + "=\"" + state.getDefinitionId() + "\" "
+ MODCOUNT_ATTRIBUTE + "=\"" + state.getModCount() + "\" "
+ NODETYPE_ATTRIBUTE + "=\"" + encodedNodeType + "\">\n");

Expand Down Expand Up @@ -601,7 +601,7 @@ protected void store(NodeState state) throws ItemStateException {
ChildNodeEntry entry = (ChildNodeEntry) iter.next();
writer.write("\t\t<" + NODE_ELEMENT + " "
+ NAME_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(entry.getName().toString()) + "\" "
+ UUID_ATTRIBUTE + "=\"" + entry.getId().getUUID().toString() + "\">\n");
+ UUID_ATTRIBUTE + "=\"" + entry.getId() + "\">\n");
writer.write("\t\t</" + NODE_ELEMENT + ">\n");
}
writer.write("\t</" + NODES_ELEMENT + ">\n");
Expand Down Expand Up @@ -655,7 +655,7 @@ protected void store(PropertyState state) throws ItemStateException {
writer.write("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
writer.write("<" + PROPERTY_ELEMENT + " "
+ NAME_ATTRIBUTE + "=\"" + Text.encodeIllegalXMLCharacters(state.getName().toString()) + "\" "
+ PARENTUUID_ATTRIBUTE + "=\"" + state.getParentId().getUUID() + "\" "
+ PARENTUUID_ATTRIBUTE + "=\"" + state.getParentId() + "\" "
+ MULTIVALUED_ATTRIBUTE + "=\"" + Boolean.toString(state.isMultiValued()) + "\" "
+ DEFINITIONID_ATTRIBUTE + "=\"" + state.getDefinitionId().toString() + "\" "
+ MODCOUNT_ATTRIBUTE + "=\"" + state.getModCount() + "\" "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public void handleMissingChildNode(NoSuchItemStateException exception,
log.error("Node {} ({}) has missing child '{}' ({})",
new Object[]{
resolver.getJCRPath(path),
node.getNodeId().getUUID().toString(),
node.getNodeId(),
resolver.getJCRName(child.getName()),
child.getId().getUUID().toString()
child.getId()
});
throw exception;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public String getExcerpt(NodeId id, int maxFragments, int maxFragmentSize)
IndexReader reader = index.getIndexReader();
try {
checkRewritten(reader);
Term idTerm = new Term(FieldNames.UUID, id.getUUID().toString());
Term idTerm = new Term(FieldNames.UUID, id.toString());
TermDocs tDocs = reader.termDocs(idTerm);
int docNumber;
Document doc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ public Hits getHits() throws IOException {
}
while (entries.hasNext()) {
NodeId childId = ((ChildNodeEntry) entries.next()).getId();
Term uuidTerm = new Term(FieldNames.UUID, childId.getUUID().toString());
Term uuidTerm = new Term(FieldNames.UUID, childId.toString());
TermDocs docs = reader.termDocs(uuidTerm);
try {
if (docs.next()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ public Object visit(PropertyFunctionQueryNode node, Object data) {
try {
NodeId id = hmgr.resolveNodePath(session.getQPath(node.getStringValue()));
if (id != null) {
query = new SimilarityQuery(id.getUUID().toString(), analyzer);
query = new SimilarityQuery(id.toString(), analyzer);
} else {
query = new BooleanQuery();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ protected Document createDoc() throws RepositoryException {
// special fields
// UUID
doc.add(new Field(
FieldNames.UUID, node.getNodeId().getUUID().toString(),
FieldNames.UUID, node.getNodeId().toString(),
Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
try {
// parent UUID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ protected QueryHitsQueryScorer(IndexReader reader,
Set sortedDocs = new TreeSet();
try {
while ((node = hits.nextScoreNode()) != null) {
String uuid = node.getNodeId().getUUID().toString();
String uuid = node.getNodeId().toString();
Term id = new Term(FieldNames.UUID, uuid);
TermDocs tDocs = reader.termDocs(id);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ public Iterable<NodeId> getWeaklyReferringNodes(NodeId id)
IndexSearcher searcher = new IndexSearcher(reader);
try {
Query q = new TermQuery(new Term(
FieldNames.WEAK_REFS, id.getUUID().toString()));
FieldNames.WEAK_REFS, id.toString()));
searcher.search(q, new HitCollector() {
public void collect(int doc, float score) {
docs.add(doc);
Expand Down

0 comments on commit c034838

Please sign in to comment.