gpt4 book ai didi

xdi2.core.syntax.XDIStatement类的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 02:49:05 26 4
gpt4 key购买 nike

本文整理了Java中xdi2.core.syntax.XDIStatement类的一些代码示例,展示了XDIStatement类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XDIStatement类的具体详情如下:
包路径:xdi2.core.syntax.XDIStatement
类名称:XDIStatement

XDIStatement介绍

暂无

代码示例

代码示例来源:origin: projectdanube/xdi2

@Override
  public XDIStatement convert(String string) {

    return XDIStatement.create(string);
  }
}

代码示例来源:origin: projectdanube/xdi2

XDIAddress contextNodeXDIAddress = XDIstatement.getContextNodeXDIAddress();
Graph resolvedGraph = this.resolveGraph(contextNodeXDIAddress);
XDIAddress resolvedcontextNodeXDIAddress = this.resolveXDIAddress(contextNodeXDIAddress);
if (XDIstatement.isContextNodeStatement()) {
  XDIArc contextNodeXDIArc = XDIstatement.getContextNodeXDIArc();
  resolvedStatementAddress = XDIStatement.fromContextNodeComponents(
      resolvedcontextNodeXDIAddress, 
      contextNodeXDIArc);
} else if (XDIstatement.isRelationStatement()) {
  XDIAddress relationAddress = XDIstatement.getRelationXDIAddress();
  XDIAddress targetXDIAddress = XDIstatement.getTargetXDIAddress();
  resolvedStatementAddress = XDIStatement.fromRelationComponents(
      resolvedcontextNodeXDIAddress, 
      relationAddress, 
      resolvedtargetXDIAddress);
} else if (XDIstatement.isLiteralStatement()) {
  Object literalData = XDIstatement.getLiteralData();
  resolvedStatementAddress = XDIStatement.fromLiteralComponents(
      resolvedcontextNodeXDIAddress, 
      literalData);

代码示例来源:origin: projectdanube/xdi2

private static XDIAddress targetXDIAddressForTargetXDIStatement(XDIStatement targetXDIStatement) {
  if (targetXDIStatement.isContextNodeStatement()) {
    return targetXDIStatement.getTargetXDIAddress();
  } else {
    return targetXDIStatement.getContextNodeXDIAddress();
  }
}

代码示例来源:origin: projectdanube/xdi2

public Object getLiteralData() {

    if (this.isLiteralStatement()) {

      return this.getObject();
    }

    return null;
  }
}

代码示例来源:origin: projectdanube/xdi2

public XDIAddress getRelationXDIAddress() {
  if (this.isRelationStatement()) {
    return (XDIAddress) this.getPredicate();
  }
  return null;
}

代码示例来源:origin: projectdanube/xdi2

public void executeGetOnStatement(XDIStatement targetStatement, GetOperation operation, Graph operationResultGraph, ExecutionContext executionContext) throws Xdi2MessagingException {
  if (targetStatement.isContextNodeStatement())
    this.executeGetOnContextNodeStatement(targetStatement, operation, operationResultGraph, executionContext);
  else if (targetStatement.isRelationStatement())
    this.executeGetOnRelationStatement(targetStatement, operation, operationResultGraph, executionContext);
  else if (targetStatement.isLiteralStatement())
    this.executeGetOnLiteralStatement(targetStatement, operation, operationResultGraph, executionContext);
  else
    throw new Xdi2MessagingException("Unknown statement type: " + targetStatement.getClass().getCanonicalName(), null, executionContext);
}

代码示例来源:origin: projectdanube/xdi2

XDIAddress rootXDIAddress = XDIAddressUtil.extractXDIAddress(XDIstatement.getContextNodeXDIAddress(), XdiPeerRoot.class, false, false, true, false, false);
if (XDIstatement.isContextNodeStatement()) {
  XDIAddress subjectXDIAddress = XDIstatement.getContextNodeXDIAddress();
  if (rootXDIAddress != null) subjectXDIAddress = XDIAddressUtil.localXDIAddress(subjectXDIAddress, - rootXDIAddress.getNumXDIArcs());
  if (subjectXDIAddress == null) subjectXDIAddress = XDIConstants.XDI_ADD_ROOT;
  XDIArc objectXDIArc = XDIstatement.getContextNodeXDIArc();
} else if (XDIstatement.isRelationStatement()) {
  XDIAddress subjectXDIAddress = XDIstatement.getContextNodeXDIAddress();
  if (rootXDIAddress != null) subjectXDIAddress = XDIAddressUtil.localXDIAddress(subjectXDIAddress, - rootXDIAddress.getNumXDIArcs());
  if (subjectXDIAddress == null) subjectXDIAddress = XDIConstants.XDI_ADD_ROOT;
  XDIAddress predicateXDIAddress = XDIstatement.getRelationXDIAddress();
  XDIAddress objectXDIAddress = XDIstatement.getTargetXDIAddress();
} else if (XDIstatement.isLiteralStatement()) {
  XDIAddress subjectXDIAddress = XDIstatement.getContextNodeXDIAddress();
  if (rootXDIAddress != null) subjectXDIAddress = XDIAddressUtil.localXDIAddress(subjectXDIAddress, - rootXDIAddress.getNumXDIArcs());
  if (subjectXDIAddress == null) subjectXDIAddress = XDIConstants.XDI_ADD_ROOT;
  Object literalData = XDIstatement.getLiteralData();
  throw new Xdi2RuntimeException("Invalid statement: " + XDIstatement.toString() + " (" + XDIstatement.getClass().getName() + ")");

代码示例来源:origin: projectdanube/xdi2

@Override
public Statement getStatement(XDIStatement statement) {
  ContextNode baseContextNode = this.getDeepContextNode(statement.getSubject(), false);
  if (baseContextNode == null) return null;
  if (statement.isContextNodeStatement()) {
    ContextNode contextNode = baseContextNode.getContextNode(statement.getContextNodeXDIArc(), false);
    return contextNode == null ? null : contextNode.getStatement();
  } else if (statement.isRelationStatement()) {
    Relation relation = baseContextNode.getRelation(statement.getRelationXDIAddress(), statement.getTargetXDIAddress());
    return relation == null ? null : relation.getStatement();
  } else if (statement.isLiteralStatement()) {
    LiteralNode literalNode = baseContextNode.getLiteralNode(statement.getLiteralData());
    return literalNode == null ? null : literalNode.getStatement();
  }
  return null;
}

代码示例来源:origin: projectdanube/xdi2

@Override
public Statement setStatement(XDIStatement statement) {
  // set the statement
  if (statement.isContextNodeStatement()) {
    ContextNode contextNode = (ContextNode) this.setDeepNode(statement.getTargetXDIAddress());
    return contextNode.getStatement();
  } else if (statement.isRelationStatement()) {
    ContextNode contextNode = (ContextNode) this.setDeepNode(statement.getContextNodeXDIAddress());
    Relation relation = contextNode.setRelation(statement.getRelationXDIAddress(), statement.getTargetXDIAddress());
    return relation.getStatement();
  } else if (statement.isLiteralStatement()) {
    ContextNode contextNode = (ContextNode) this.setDeepNode(statement.getContextNodeXDIAddress());
    LiteralNode literalNode = contextNode.setLiteralNode(statement.getLiteralData());
    return literalNode.getStatement();
  } else {
    throw new Xdi2GraphException("Invalid statement: " + statement);
  }
}

代码示例来源:origin: projectdanube/xdi2

public void testComponents() throws Exception {
  XDIStatement contextNodeStatement = XDIStatement.create("=markus//[<#email>]");
  XDIStatement contextNodeStatement2 = XDIStatement.fromComponents(XDIAddress.create("=markus"), XDIConstants.STRING_CONTEXT, XDIArc.create("[<#email>]"));
  XDIStatement contextNodeStatement3 = XDIStatement.fromContextNodeComponents(XDIAddress.create("=markus"), XDIArc.create("[<#email>]"));
  assertEquals(contextNodeStatement.getSubject(), XDIAddress.create("=markus"));
  assertEquals(contextNodeStatement.getPredicate(), XDIConstants.STRING_CONTEXT);
  assertEquals(contextNodeStatement.getObject(), XDIArc.create("[<#email>]"));
  assertEquals(contextNodeStatement, contextNodeStatement2);
  assertEquals(contextNodeStatement, contextNodeStatement3);
  XDIStatement relationStatement = XDIStatement.create("=markus/+friend/=animesh");
  XDIStatement relationStatement2 = XDIStatement.fromComponents(XDIAddress.create("=markus"), XDIAddress.create("+friend"), XDIAddress.create("=animesh"));
  XDIStatement relationStatement3 = XDIStatement.fromRelationComponents(XDIAddress.create("=markus"), XDIAddress.create("+friend"), XDIAddress.create("=animesh"));
  assertEquals(relationStatement, relationStatement2);
  assertEquals(relationStatement, relationStatement3);
  assertEquals(relationStatement.getSubject(), XDIAddress.create("=markus"));
  assertEquals(relationStatement.getPredicate(), XDIAddress.create("+friend"));
  assertEquals(relationStatement.getObject(), XDIAddress.create("=animesh"));
  XDIStatement literalStatement = XDIStatement.create("=markus<#name>/&/\"Markus Sabadello\"");
  XDIStatement literalStatement2 = XDIStatement.fromComponents(XDIAddress.create("=markus<#name>"), XDIConstants.XDI_ARC_LITERAL, "Markus Sabadello");
  XDIStatement literalStatement3 = XDIStatement.fromLiteralComponents(XDIAddress.create("=markus<#name>"), "Markus Sabadello");
  assertEquals(literalStatement.getSubject(), XDIAddress.create("=markus<#name>"));
  assertEquals(literalStatement.getPredicate(), XDIConstants.XDI_ARC_LITERAL.toString());
  assertEquals(literalStatement.getObject(), "Markus Sabadello");
  assertEquals(literalStatement, literalStatement2);
  assertEquals(literalStatement, literalStatement3);
}

代码示例来源:origin: projectdanube/xdi2

XDIAddress relativeNodeXDIAddress = relativeTargetXDIStatement == null ? null : relativeTargetXDIStatement.getContextNodeXDIAddress();
  if (relativeTargetXDIStatement.isContextNodeStatement()) {
        ! Arrays.asList(contributorMount.contextNodeXDIArcs()).contains(relativeTargetXDIStatement.getContextNodeXDIArc())) {
      if (log.isDebugEnabled()) log.debug("Skipping contributor (doesn't like context node arc " + relativeTargetXDIStatement.getContextNodeXDIArc() + ") " + contributor.getClass().getSimpleName() + " with operation " + operation.getOperationXDIAddress() + " on contributor address " + contributorAddress + " and relative target statement " + relativeTargetXDIStatement + ".");
      continue;
        ! Arrays.asList(contributorMount.targetXDIAddresses()).contains(relativeTargetXDIStatement.getTargetXDIAddress())) {
      if (log.isDebugEnabled()) log.debug("Skipping contributor (doesn't like target context node address " + relativeTargetXDIStatement.getTargetXDIAddress() + ") " + contributor.getClass().getSimpleName() + " with operation " + operation.getOperationXDIAddress() + " on contributor address " + contributorAddress + " and relative target statement " + relativeTargetXDIStatement + ".");
      continue;
  if (relativeTargetXDIStatement.isRelationStatement()) {
        ! Arrays.asList(contributorMount.relationXDIAddresses()).contains(relativeTargetXDIStatement.getRelationXDIAddress())) {
      if (log.isDebugEnabled()) log.debug("Skipping contributor (doesn't like relation arc " + relativeTargetXDIStatement.getRelationXDIAddress() + ") " + contributor.getClass().getSimpleName() + " with operation " + operation.getOperationXDIAddress() + " on contributor address " + contributorAddress + " and relative target statement " + relativeTargetXDIStatement + ".");
      continue;
        ! Arrays.asList(contributorMount.targetXDIAddresses()).contains(relativeTargetXDIStatement.getTargetXDIAddress())) {
      if (log.isDebugEnabled()) log.debug("Skipping contributor (doesn't like target context node address " + relativeTargetXDIStatement.getTargetXDIAddress() + ") " + contributor.getClass().getSimpleName() + " with operation " + operation.getOperationXDIAddress() + " on contributor address " + contributorAddress + " and relative target statement " + relativeTargetXDIStatement + ".");
      continue;
  if (relativeTargetXDIStatement.isLiteralStatement()) {
  XDIAddress nextRelativeNodeXDIAddress = nextRelativeTargetXDIStatement == null ? null : nextRelativeTargetXDIStatement.getContextNodeXDIAddress();

代码示例来源:origin: projectdanube/xdi2

if (XDIDictionaryConstants.XDI_ADD_REF.equals(targetStatement.getRelationXDIAddress())) doFollowTargetSubject = false;
if (XDIDictionaryConstants.XDI_ADD_REP.equals(targetStatement.getRelationXDIAddress())) doFollowTargetSubject = false;
if (XDIDictionaryConstants.XDI_ADD_IS_REF.equals(targetStatement.getRelationXDIAddress())) doFollowTargetSubject = false;
if (XDIDictionaryConstants.XDI_ADD_IS_REP.equals(targetStatement.getRelationXDIAddress())) doFollowTargetSubject = false;
if (XDIDictionaryConstants.XDI_ADD_REF.equals(targetStatement.getRelationXDIAddress())) doFollowTargetObject = false;
if (XDIDictionaryConstants.XDI_ADD_REP.equals(targetStatement.getRelationXDIAddress())) doFollowTargetObject = false;
if (XDIDictionaryConstants.XDI_ADD_IS_REF.equals(targetStatement.getRelationXDIAddress())) doFollowTargetObject = false;
if (XDIDictionaryConstants.XDI_ADD_IS_REP.equals(targetStatement.getRelationXDIAddress())) doFollowTargetObject = false;
if (! targetStatement.isRelationStatement()) doFollowTargetObject = false;
if (targetStatement.isRelationStatement() && XDIConstants.XDI_ADD_COMMON_VARIABLE.equals(targetStatement.getTargetXDIAddress())) doFollowTargetObject = false;
XDIAddress followedTargetSubject = doFollowTargetSubject ? followAllRefRepRelations(targetStatement.getSubject(), operation, executionContext) : targetStatement.getSubject();
Object followedTargetObject = doFollowTargetObject ? followAllRefRepRelations((XDIAddress) targetStatement.getObject(), operation, executionContext) : targetStatement.getObject();
if (followedTargetSubject != targetStatement.getSubject() || followedTargetObject != targetStatement.getObject()) {
  targetStatement = XDIStatement.fromComponents(followedTargetSubject, targetStatement.getPredicate(), followedTargetObject);
if (XDIDictionaryConstants.XDI_ADD_REF.equals(targetStatement.getRelationXDIAddress()) ||
    XDIDictionaryConstants.XDI_ADD_REP.equals(targetStatement.getRelationXDIAddress())) {

代码示例来源:origin: projectdanube/xdi2

assertEquals(statement.getSubject(), parser.parseXDIAddress("=markus[<#email>]<*!1>"));
assertEquals(statement.getPredicate(), parser.parseXDIArc("&"));
assertEquals(statement.getObject(), "xxx");
assertEquals(statement.getContextNodeXDIAddress(), parser.parseXDIAddress("=markus[<#email>]<*!1>"));
assertNull(statement.getContextNodeXDIArc());
assertNull(statement.getTargetXDIAddress());
assertEquals(statement.getLiteralData(), "xxx");
assertEquals(statement.getSubject().getNumXDIArcs(), 3);
assertEquals(statement.getSubject().getXDIArc(0), statement.getSubject().getFirstXDIArc());
assertEquals(statement.getSubject().getXDIArc(2), statement.getSubject().getLastXDIArc());
assertEquals(statement.getSubject().getXDIArc(0), parser.parseXDIArc("=markus"));
assertEquals(statement.getSubject().getXDIArc(0).getCs(), XDIConstants.CS_AUTHORITY_PERSONAL);
assertEquals(statement.getSubject().getXDIArc(0).getLiteral(), "markus");
assertNull(statement.getSubject().getXDIArc(0).getXRef());
assertEquals(statement.getSubject().getXDIArc(1), parser.parseXDIArc("[<#email>]"));
assertEquals(statement.getSubject().getXDIArc(1).getCs(), XDIConstants.CS_CLASS_UNRESERVED);
assertTrue(statement.getSubject().getXDIArc(1).isCollection());
assertTrue(statement.getSubject().getXDIArc(1).isAttribute());
assertEquals(statement.getSubject().getXDIArc(1).getLiteral(), "email");
assertNull(statement.getSubject().getXDIArc(1).getXRef());
assertEquals(statement.getSubject().getXDIArc(2), parser.parseXDIArc("<*!1>"));
assertEquals(statement.getSubject().getXDIArc(2).getCs(), XDIConstants.CS_INSTANCE_UNORDERED);
assertFalse(statement.getSubject().getXDIArc(2).isCollection());
assertTrue(statement.getSubject().getXDIArc(2).isAttribute());
assertEquals(statement.getSubject().getXDIArc(2).getLiteral(), "1");
assertNull(statement.getSubject().getXDIArc(2).getXRef());

代码示例来源:origin: projectdanube/xdi2

private void writeStatement(BufferedWriter bufferedWriter, XDIStatement XDIstatement) throws IOException {
  // write the statement
  this.writeContextNodeXDIAddress(bufferedWriter, XDIstatement.getSubject());
  this.writeSeparator(bufferedWriter);
  this.writePredicate(bufferedWriter, XDIstatement.getPredicate());
  this.writeSeparator(bufferedWriter);
  if (XDIstatement.isContextNodeStatement()) {
    this.writeContextNodeXDIArc(bufferedWriter, XDIstatement.getSubject(), (XDIArc) XDIstatement.getObject());
  } else if (XDIstatement.isRelationStatement()) {
    this.writeContextNodeXDIAddress(bufferedWriter, (XDIAddress) XDIstatement.getObject());
  } else if (XDIstatement.isLiteralStatement()) {
    this.writeLiteralData(bufferedWriter, XDIstatement.getObject());
  }
}

代码示例来源:origin: projectdanube/xdi2

assertTrue(XDIStatement.create(contextNodeStatement).isContextNodeStatement());
assertFalse(XDIStatement.create(contextNodeStatement).isRelationStatement());
assertFalse(XDIStatement.create(contextNodeStatement).isLiteralStatement());
assertFalse(XDIStatement.create(relationStatement).isContextNodeStatement());
assertTrue(XDIStatement.create(relationStatement).isRelationStatement());
assertFalse(XDIStatement.create(relationStatement).isLiteralStatement());
assertFalse(XDIStatement.create(literalStatement).isContextNodeStatement());
assertFalse(XDIStatement.create(literalStatement).isRelationStatement());
assertTrue(XDIStatement.create(literalStatement).isLiteralStatement());
  graph.setStatement(XDIStatement.create(invalidStatement));

代码示例来源:origin: projectdanube/xdi2

@Override
public void executeSetOnRelationStatement(XDIStatement relationStatement, SetOperation operation, Graph operationResultGraph, ExecutionContext executionContext) throws Xdi2MessagingException {
  XDIAddress contextNodeXDIAddress = relationStatement.getContextNodeXDIAddress();
  XDIAddress relationXDIaddress = relationStatement.getRelationXDIAddress();
  XDIAddress targetXDIAddress = relationStatement.getTargetXDIAddress();
  this.getGraph().setDeepContextNode(contextNodeXDIAddress).setRelation(relationXDIaddress, targetXDIAddress);
}

代码示例来源:origin: projectdanube/xdi2

@Override
public XDIStatement targetStatement(XDIStatement targetStatement, Operation operation, Graph resultGraph, ExecutionContext executionContext) throws Xdi2MessagingException {
  if (operation instanceof DoOperation) return targetStatement;
  // encrypt literals
  if (targetStatement.isLiteralStatement()) {
    XDIAddress contextNodeXDIAddress = targetStatement.getContextNodeXDIAddress();
    Object literalData = targetStatement.getLiteralData();
    String literalDataString = AbstractLiteralNode.literalDataToString(literalData);
    String encryptedLiteralDataString;
    try {
      encryptedLiteralDataString = this.getLiteralCryptoService().encryptLiteralDataString(literalDataString);
    } catch (Exception ex) {
      throw new Xdi2MessagingException("Problem while encrypting literal string: " + ex.getMessage(), ex, executionContext);
    }
    return XDIStatement.fromLiteralComponents(contextNodeXDIAddress, encryptedLiteralDataString);
  }
  // done
  return targetStatement;
}

代码示例来源:origin: projectdanube/xdi2

public XDIAddress getTargetXDIAddress() {
  if (this.isContextNodeStatement()) {
    return XDIAddressUtil.concatXDIAddresses(this.getSubject(), (XDIArc) this.getObject());
  } else if (this.isRelationStatement()) {
    return (XDIAddress) this.getObject();
  }
  return null;
}

代码示例来源:origin: projectdanube/xdi2

static XDIStatement fromComponents(String string, XDIAddress subject, Object predicate, Object object) {
  if (predicate instanceof String && 
      XDIConstants.STRING_CONTEXT.equals(predicate) && 
      object instanceof XDIArc && 
      ! XDIConstants.XDI_ADD_ROOT.equals(object.toString())) {
    return fromContextNodeComponents(string, subject, (XDIArc) object);
  } else if (predicate instanceof XDIAddress && 
      ! XDIConstants.STRING_CONTEXT.equals(predicate.toString()) && 
      ! XDIConstants.XDI_ARC_LITERAL.toString().equals(predicate.toString()) && 
      object instanceof XDIAddress) {
    return fromRelationComponents(string, subject, (XDIAddress) predicate, (XDIAddress) object);
  } else if (predicate instanceof XDIArc && 
      XDIConstants.XDI_ARC_LITERAL.equals(predicate) && 
      AbstractLiteralNode.isValidLiteralData(object)) {
    return fromLiteralComponents(string, subject, object);
  } else {
    throw new ParserException("Invalid statement components: " + subject + "/" + predicate + "/" + object);
  }
}

代码示例来源:origin: projectdanube/xdi2

public static XDIStatement fromRelationComponents(XDIAddress contextNodeXDIAddress, XDIAddress relationAddress, XDIAddress targetXDIAddress) {
  return fromRelationComponents(null, contextNodeXDIAddress, relationAddress, targetXDIAddress);
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com