gpt4 book ai didi

xdi2.core.syntax.XDIStatement.getSubject()方法的使用及代码示例

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

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

XDIStatement.getSubject介绍

暂无

代码示例

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

public XDIAddress getContextNodeXDIAddress() {
  return this.getSubject();
}

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

private void putStatementIntoJsonObject(XDIStatement XDIstatement, JsonObject jsonObject) throws IOException {
  // nested JSON object?
  if (this.tryPutStatementIntoInnerJsonObject(XDIstatement, jsonObject)) return;
  // add the object
  String key = XDIstatement.getSubject() + "/" + XDIstatement.getPredicate();
  addObjectToJsonObject(XDIstatement, jsonObject, key);
}

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

/**
 * Removes a start address from a statement.
 * E.g. for =a*b*c*d/&/... and =a*b, this returns *c*d/&/...
 */
public static XDIStatement removeStartXDIStatement(final XDIStatement statement, final XDIAddress start, final boolean variablesInAddress, boolean variablesInStart) {
  if (statement == null) throw new NullPointerException();
  if (start == null) throw new NullPointerException();
  XDIStatement result = null;
  try {
    XDIAddress subject;
    Object predicate;
    Object object;
    // subject
    subject = XDIAddressUtil.removeStartXDIAddress(statement.getSubject(), start, variablesInAddress, variablesInStart);
    if (subject == null) { result = null; return result; }
    // predicate
    predicate = statement.getPredicate();
    // object
    object = statement.getObject();
    { result = XDIStatement.fromComponents(subject, predicate, object); return result; }
  } finally {
    if (log.isTraceEnabled()) log.trace("removeStartXDIStatement(" + statement + "," + start + "," + variablesInAddress + "," + variablesInStart + ") --> " + result);
  }
}

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

subject = XDIAddressUtil.concatXDIAddresses(XDIaddress, statement.getSubject());

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

private static JsonArray makeGom(XDIStatement statement) {
  JsonArray gom = new JsonArray();
  gom.add(makeGom(statement.getSubject()));
  gom.add(makeGom(statement.getPredicate()));
  if (statement.getObject() instanceof XDIAddress)
    gom.add(makeGom((XDIAddress) statement.getObject()));
  else if (statement.getObject() instanceof XDIArc)
    gom.add(makeGom((XDIArc) statement.getObject()));
  else
    gom.add(AbstractLiteralNode.literalDataToJsonElement(statement.getObject()));
  return gom;
}

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

private boolean tryPutStatementIntoInnerJsonObject(XDIStatement XDIstatement, JsonObject jsonObject) throws IOException {
  XDIArc subjectFirstArc = XDIstatement.getSubject().getFirstXDIArc();
  if (subjectFirstArc == null || (! subjectFirstArc.hasXRef()) || (! subjectFirstArc.getXRef().hasPartialSubjectAndPredicate())) return false;
  XDIAddress innerRootSubject = XDIstatement.getSubject().getFirstXDIArc().getXRef().getPartialSubject();
  XDIAddress innerRootPredicate = XDIstatement.getSubject().getFirstXDIArc().getXRef().getPartialPredicate();
  XDIStatement reducedStatementAddress = XDIStatementUtil.removeStartXDIStatement(XDIstatement, XDIAddress.fromComponent(subjectFirstArc));
  if (reducedStatementAddress == null) return false;
  // find the inner root JSON array
  String innerRootKey = "" + innerRootSubject + "/" + innerRootPredicate;
  JsonArray innerRootJsonArray = (JsonArray) jsonObject.get(innerRootKey);
  if (innerRootJsonArray == null) {
    innerRootJsonArray = new JsonArray();
    jsonObject.add(innerRootKey, innerRootJsonArray);
  }
  // find the inner root JSON object
  JsonObject innerRootJsonObject = findJsonObjectInJsonArray(innerRootJsonArray);
  if (innerRootJsonObject == null) {
    innerRootJsonObject = new JsonObject();
    innerRootJsonArray.add(innerRootJsonObject);
  }
  // put the statement into the inner root JSON object
  this.putStatementIntoJsonObject(reducedStatementAddress, innerRootJsonObject);
  // done
  return true;
}

代码示例来源: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

@Override
public XDIStatement targetStatement(XDIStatement targetStatement, Operation operation, Graph operationResultGraph, ExecutionContext executionContext) throws Xdi2MessagingException {
  if (! (operation instanceof SetOperation)) return targetStatement;
  XDIAddress substitutedTargetSubject = substituteAddress(targetStatement.getSubject(), executionContext);
  Object substitutedTargetPredicate = targetStatement.getPredicate() instanceof XDIAddress ? substituteAddress((XDIAddress) targetStatement.getPredicate(), executionContext) : targetStatement.getPredicate();
  Object substitutedTargetObject = substituteObject(targetStatement.getObject(), executionContext);
  if (substitutedTargetSubject == targetStatement.getSubject() && substitutedTargetPredicate == targetStatement.getPredicate() && substitutedTargetObject == targetStatement.getObject()) return targetStatement;
  return XDIStatement.fromComponents(substitutedTargetSubject, substitutedTargetPredicate, substitutedTargetObject);
}

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

@Override
  public boolean evaluateInternal(PolicyEvaluationContext policyEvaluationContext) {

    // check if subject address and object address are the same

    XDIAddress subject = policyEvaluationContext.resolveXDIAddress(this.getXDIStatement().getSubject());
    XDIAddress object = policyEvaluationContext.resolveXDIAddress((XDIAddress) this.getXDIStatement().getObject());

    if (subject == null || object == null) return false;

    if (subject.equals(object)) return true;

    // done

    return false;
  }
}

代码示例来源: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

@Override
  public boolean evaluateInternal(PolicyEvaluationContext policyEvaluationContext) {

    ContextNode subject = policyEvaluationContext.getContextNode(this.getXDIStatement().getSubject());
    ContextNode object = policyEvaluationContext.getContextNode((XDIAddress) this.getXDIStatement().getObject());

    if (subject == null || object == null) return false;

    if (subject.containsLiteralNode()) {

      if (! (object.containsLiteralNode())) return false;

      Object subjectLiteralData = subject.getLiteralNode().getLiteralData();
      Object objectLiteralData = object.getLiteralNode().getLiteralData();

      if (subjectLiteralData == null || objectLiteralData == null) return false;

      return AbstractLiteralNode.LITERALDATACOMPARATOR.compare(subjectLiteralData, objectLiteralData) < 0;
    }

    return false;
  }
}

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

@Override
  public boolean evaluateInternal(PolicyEvaluationContext policyEvaluationContext) {

    ContextNode subject = policyEvaluationContext.getContextNode(this.getXDIStatement().getSubject());
    ContextNode object = policyEvaluationContext.getContextNode((XDIAddress) this.getXDIStatement().getObject());

    if (subject == null || object == null) return false;

    if (subject.containsLiteralNode()) {

      if (! (object.containsLiteralNode())) return false;

      Object subjectLiteralData = subject.getLiteralNode().getLiteralData();
      Object objectLiteralData = object.getLiteralNode().getLiteralData();

      if (subjectLiteralData == null || objectLiteralData == null) return false;

      return AbstractLiteralNode.LITERALDATACOMPARATOR.compare(subjectLiteralData, objectLiteralData) > 0;
    }

    return false;
  }
}

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

@Override
  public boolean evaluateInternal(PolicyEvaluationContext policyEvaluationContext) {

    ContextNode subject = policyEvaluationContext.getContextNode(this.getXDIStatement().getSubject());
    ContextNode object = policyEvaluationContext.getContextNode((XDIAddress) this.getXDIStatement().getObject());

    if (subject == null || object == null) return false;

    if (subject.containsLiteralNode()) {

      if (! (object.containsLiteralNode())) return false;

      String subjectLiteralData = subject.getLiteralNode().getLiteralDataString();
      String objectLiteralData = object.getLiteralNode().getLiteralDataString();

      if (subjectLiteralData == null || objectLiteralData == null) return false;

      return Pattern.matches(objectLiteralData, subjectLiteralData);
    }

    return false;
  }
}

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

assertEquals(statement.getSubject(), parser.parseXDIAddress("=markus[<#email>]<*!1>"));
assertEquals(statement.getPredicate(), parser.parseXDIArc("&"));
assertEquals(statement.getObject(), "xxx");
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

@Override
  public boolean evaluateInternal(PolicyEvaluationContext policyEvaluationContext) {

    ContextNode subject = policyEvaluationContext.getContextNode(this.getXDIStatement().getSubject());
    ContextNode object = policyEvaluationContext.getContextNode((XDIAddress) this.getXDIStatement().getObject());

    if (subject == null || object == null) return false;

    if (subject.containsLiteralNode()) {

      if (! (object.containsLiteralNode())) return false;

      Object subjectLiteralData = subject.getLiteralNode().getLiteralData();
      Object objectLiteralData = object.getLiteralNode().getLiteralData();

      if (subjectLiteralData == null || objectLiteralData == null) return false;

      return AbstractLiteralNode.isLiteralDataEqual(subjectLiteralData, objectLiteralData);
    }

    return false;
  }
}

代码示例来源: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

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()) {

代码示例来源: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

assertEquals(statement.getSubject(), parser.parseXDIAddress("=markus<#email>"));
assertEquals(statement.getPredicate(), parser.parseXDIArc("&"));
assertEquals(statement.getPredicate(), XDIConstants.XDI_ARC_LITERAL);
assertEquals(statement.getSubject(), parser.parseXDIAddress("=markus"));
assertEquals(statement.getPredicate(), parser.parseXDIAddress("+friend"));
assertEquals(statement.getObject(), parser.parseXDIAddress("=neustar*animesh"));
assertEquals(statement.getSubject(), parser.parseXDIAddress("=neustar*animesh<#email>"));
assertEquals(statement.getPredicate(), parser.parseXDIAddress("&"));
assertEquals(statement.getObject(), "animesh@gmail.com");
assertEquals(statement.getSubject(), parser.parseXDIAddress("=neustar*animesh<#age>"));
assertEquals(statement.getPredicate(), parser.parseXDIAddress("&"));
assertEquals(statement.getObject(), Double.valueOf(99));
assertEquals(statement.getSubject(), parser.parseXDIAddress("=neustar*animesh<#smoker>"));
assertEquals(statement.getPredicate(), parser.parseXDIAddress("&"));
assertEquals(statement.getObject(), Boolean.valueOf(false));
assertEquals(statement.getSubject(), parser.parseXDIAddress("=neustar*animesh<#color>"));
assertEquals(statement.getPredicate(), parser.parseXDIAddress("&"));
assertNull(statement.getObject());
assertEquals(statement.getSubject(), parser.parseXDIAddress("=neustar*animesh"));
assertEquals(statement.getPredicate(), parser.parseXDIAddress("+friend"));
assertEquals(statement.getObject(), parser.parseXDIAddress("=markus"));

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

assertEquals(reducedContextStatement.getSubject(), XDIAddress.create("<#full>"));
assertEquals(reducedContextStatement.getPredicate(), XDIAddress.create(""));
assertEquals(reducedContextStatement.getObject(), "<#name>");
assertEquals(reducedLiteralStatement.getSubject(), XDIAddress.create("<#name>&"));
assertEquals(reducedLiteralStatement.getPredicate(), XDIAddress.create("&"));
assertEquals(reducedLiteralStatement.getObject(), "Markus Sabadello");
assertEquals(reducedRelationStatement1.getSubject(), XDIAddress.create("<#name>"));
assertEquals(reducedRelationStatement1.getPredicate(), XDIAddress.create("$ref"));
assertEquals(reducedRelationStatement1.getObject(), "=markus<#full><#name>");
assertEquals(reducedRelationStatement2.getSubject(), XDIAddress.create("<#name>"));
assertEquals(reducedRelationStatement2.getPredicate(), XDIAddress.create("$ref"));
assertEquals(reducedRelationStatement2.getObject(), "=markus<#full><#name>");

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