@Override public ContextNode map(LiteralNode literal) { return literal.getContextNode(); } }
@Override public LiteralNode replaceLiteralNode(LiteralNode literalNode) { String literalDataString = literalNode.getLiteralDataString(); if (literalDataString == null) return literalNode; for (Map.Entry<String, String> replacement : this.replacements.entrySet()) { literalDataString = literalDataString.replaceAll(replacement.getKey(), replacement.getValue()); } return new DummyLiteralNode(literalNode.getContextNode(), literalDataString); } }
/** * Copies a literal into another graph. * @param literalNode A literal from any graph. * @param targetGraph The target graph. * @param copyStrategy The strategy to determine what to copy. * @return The copied literal in the target graph. */ public static LiteralNode copyLiteralNode(LiteralNode literalNode, Graph targetGraph, CopyStrategy copyStrategy) { if (literalNode == null) throw new NullPointerException(); if (targetGraph == null) throw new NullPointerException(); if (copyStrategy == null) copyStrategy = DEFAULT_COPY_STRATEGY; XDIAddress literalNodeContextNodeXDIAddress = literalNode.getContextNode().getXDIAddress(); ContextNode targetContextNode = targetGraph.setDeepContextNode(literalNodeContextNodeXDIAddress); return copyLiteralNode(literalNode, targetContextNode, copyStrategy); }
@Override public int compareTo(LiteralNode other) { if (other == null || other == this) return 0; int compare; if ((compare = this.getContextNode().compareTo(other.getContextNode())) != 0) return compare; if ((compare = LITERALDATACOMPARATOR.compare(this.getLiteralData(), other.getLiteralData())) != 0) return compare; return 0; }
@Override public boolean equals(Object object) { if (object == null || ! (object instanceof LiteralNode)) return false; if (object == this) return true; LiteralNode other = (LiteralNode) object; // two literals are equal if their context nodes and their data are equal return this.getContextNode().equals(other.getContextNode()) && AbstractLiteralNode.isLiteralDataEqual(this.getLiteralData(), other.getLiteralData()); }
Dictionary.setContextNodeType(literalNode.getContextNode(), entryType);
assertEquals(XDIArc.create("$"), abcPassportV2RelationDollar.getXDIAddress()); assertEquals(XDIAddress.create("=abc[#passport]"), abcPassportV2RelationDollar.getTargetXDIAddress()); assertEquals(XDIArc.create("<#number>"), abcPassport1NumberLiteral.getContextNode().getXDIArc()); assertEquals("987654321", abcPassport1NumberLiteral.getLiteralData()); assertEquals(XDIArc.create("<#country>"), abcPassport1CountryLiteral.getContextNode().getXDIArc()); assertEquals("Canada", abcPassport1CountryLiteral.getLiteralData()); assertEquals(XDIArc.create("<$t>"), abcPassport1DLiteral.getContextNode().getXDIArc()); assertEquals("2005-01-01T00:00:00Z", abcPassport1DLiteral.getLiteralData()); assertEquals(XDIArc.create("<#number>"), abcPassport2NumberLiteral.getContextNode().getXDIArc()); assertEquals("123456789", abcPassport2NumberLiteral.getLiteralData()); assertEquals(XDIArc.create("<#country>"), abcPassport2CountryLiteral.getContextNode().getXDIArc()); assertEquals("New Zealand", abcPassport2CountryLiteral.getLiteralData()); assertEquals(XDIArc.create("<$t>"), abcPassport2DLiteral.getContextNode().getXDIArc()); assertEquals("2010-10-01T00:00:00Z", abcPassport2DLiteral.getLiteralData()); assertEquals(XDIArc.create("*!:uuid:1111"), abcPassportC1ContextNode.getXDIArc()); assertEquals(XDIArc.create("*!:uuid:2222"), abcPassportC2ContextNode.getXDIArc()); assertEquals(XDIAddress.create("=abc[#passport][$o]*!:uuid:2222"), abcPassportC2ContextNode.getXDIAddress()); assertEquals(XDIArc.create("<$t>"), abcPassportC1DLiteral.getContextNode().getXDIArc()); assertEquals("2010-11-11T11:11:11Z", abcPassportC1DLiteral.getLiteralData()); assertEquals(XDIArc.create("<$t>"), abcPassportC2DLiteral.getContextNode().getXDIArc()); assertEquals("2010-12-22T22:22:22Z", abcPassportC2DLiteral.getLiteralData()); assertEquals(XDIArc.create("[$v]"), abcPassportRelationV.getXDIAddress());
assertEquals(XDIArc.create("$"), abcPassportV2RelationDollar.getXDIAddress()); assertEquals(XDIAddress.create("=abc[#passport]"), abcPassportV2RelationDollar.getTargetXDIAddress()); assertEquals(XDIArc.create("<#number>"), abcPassport1NumberLiteral.getContextNode().getXDIArc()); assertEquals("987654321", abcPassport1NumberLiteral.getLiteralData()); assertEquals(XDIArc.create("<#country>"), abcPassport1CountryLiteral.getContextNode().getXDIArc()); assertEquals("Canada", abcPassport1CountryLiteral.getLiteralData()); assertEquals(XDIArc.create("<$t>"), abcPassport1LiteralD.getContextNode().getXDIArc()); assertEquals("2005-01-01T00:00:00Z", abcPassport1LiteralD.getLiteralData()); assertEquals(XDIArc.create("*!:uuid:2222"), abcPassportC2ContextNode.getXDIArc()); assertEquals(XDIAddress.create("=abc[#passport][$o]*!:uuid:2222"), abcPassportC2ContextNode.getXDIAddress()); assertEquals(XDIArc.create("<$t>"), abcPassportC1LiteralD.getContextNode().getXDIArc()); assertEquals("2010-03-03T03:03:03Z", abcPassportC1LiteralD.getLiteralData()); // MANIPULATED
abcPassportC2LiteralD.getContextNode().delete();