net.sf.saxon.om.Item.toShortString()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(71)

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

Item.toShortString介绍

[英]Provide a short string showing the contents of the item, suitable for use in error messages
[中]提供一个显示项目内容的短字符串,适合在错误消息中使用

代码示例

代码示例来源:origin: net.sf.saxon/Saxon-HE

protected static void mustBeArrayOrMap(Expression exp, Item baseItem) throws XPathException {
  XPathException exception = new XPathException("The items on the LHS of the '?' operator must be maps or arrays; but value (" +
                             baseItem.toShortString() + ") was supplied", "XPTY0004");
  exception.setIsTypeError(true);
  exception.setLocation(exp.getLocation());
  exception.setFailingExpression(exp);
  throw exception;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

protected static void mustBeArrayOrMap(Expression exp, Item baseItem) throws XPathException {
  XPathException exception = new XPathException("The items on the LHS of the '?' operator must be maps or arrays; but value (" +
                             baseItem.toShortString() + ") was supplied", "XPTY0004");
  exception.setIsTypeError(true);
  exception.setLocation(exp.getLocation());
  exception.setFailingExpression(exp);
  throw exception;
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

public static void traceItem(/*@Nullable*/ Item val, String label, Logger out) {
  if (val == null) {
    out.info(label);
  } else {
    if (val instanceof NodeInfo) {
      out.info(label + ": " + Type.displayTypeName(val) + ": "
        + Navigator.getPath((NodeInfo) val));
    } else if (val instanceof AtomicValue) {
      out.info(label + ": " + Type.displayTypeName(val) + ": "
          + val.getStringValue());
    } else if (val instanceof ArrayItem || val instanceof MapItem) {
      out.info(label + ": " + val.toShortString());
    } else if (val instanceof Function) {
      StructuredQName name = ((Function)val).getFunctionName();
      out.info(label + ": function " + (name==null ? "(anon)" : name.getDisplayName()) + "#" + ((Function)val).getArity());
    } else if (val instanceof ObjectValue) {
      Object obj = ((ObjectValue)val).getObject();
      out.info(label + ": " + obj.getClass().getName() + " = " + Err.truncate30(obj.toString()));
    } else {
      out.info(label + ": " + val.toShortString());
    }
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

public static void traceItem(/*@Nullable*/ Item val, String label, Logger out) {
  if (val == null) {
    out.info(label);
  } else {
    if (val instanceof NodeInfo) {
      out.info(label + ": " + Type.displayTypeName(val) + ": "
        + Navigator.getPath((NodeInfo) val));
    } else if (val instanceof AtomicValue) {
      out.info(label + ": " + Type.displayTypeName(val) + ": "
          + val.getStringValue());
    } else if (val instanceof ArrayItem || val instanceof MapItem) {
      out.info(label + ": " + val.toShortString());
    } else if (val instanceof Function) {
      StructuredQName name = ((Function)val).getFunctionName();
      out.info(label + ": function " + (name==null ? "(anon)" : name.getDisplayName()) + "#" + ((Function)val).getArity());
    } else if (val instanceof ObjectValue) {
      Object obj = ((ObjectValue)val).getObject();
      out.info(label + ": " + obj.getClass().getName() + " = " + Err.truncate30(obj.toString()));
    } else {
      out.info(label + ": " + val.toShortString());
    }
  }
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

/**
 * Create a string representation of an item for use in an error message
 */
public static CharSequence depict(Item item) {
  if (item instanceof NodeInfo) {
    NodeInfo node = (NodeInfo)item;
    switch (node.getNodeKind()) {
      case Type.DOCUMENT:
        return "doc(" + abbreviateURI(node.getSystemId()) + ')';
      case Type.ELEMENT:
        return '<' + node.getDisplayName() + '>';
      case Type.ATTRIBUTE:
        return '@' + node.getDisplayName();
      case Type.TEXT:
        return "text{" + truncate30(node.getStringValueCS()) + "}";
      case Type.COMMENT:
        return "<!--...-->";
      case Type.PROCESSING_INSTRUCTION:
        return "<?" + node.getLocalPart() + "...?>";
      case Type.NAMESPACE:
        return "xmlns:" + node.getLocalPart() + "=" + abbreviateURI(node.getStringValue());
      default:
        return "";
    }
  } else {
    return item.toShortString();
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

/**
 * Create a string representation of an item for use in an error message
 */
public static CharSequence depict(Item item) {
  if (item instanceof NodeInfo) {
    NodeInfo node = (NodeInfo)item;
    switch (node.getNodeKind()) {
      case Type.DOCUMENT:
        return "doc(" + abbreviateURI(node.getSystemId()) + ')';
      case Type.ELEMENT:
        return '<' + node.getDisplayName() + '>';
      case Type.ATTRIBUTE:
        return '@' + node.getDisplayName();
      case Type.TEXT:
        return "text{" + truncate30(node.getStringValueCS()) + "}";
      case Type.COMMENT:
        return "<!--...-->";
      case Type.PROCESSING_INSTRUCTION:
        return "<?" + node.getLocalPart() + "...?>";
      case Type.NAMESPACE:
        return "xmlns:" + node.getLocalPart() + "=" + abbreviateURI(node.getStringValue());
      default:
        return "";
    }
  } else {
    return item.toShortString();
  }
}

代码示例来源:origin: net.sf.saxon/Saxon-HE

out.startElement(resultMap, Untyped.getInstance(), ExplicitLocation.UNKNOWN_LOCATION, 0);
  out.startContent();
  out.characters(item.toShortString(), locationId, 0);
  out.endElement();
} else if (item instanceof ArrayItem) {
  out.startElement(resultArray, Untyped.getInstance(), ExplicitLocation.UNKNOWN_LOCATION, 0);
  out.startContent();
  out.characters(item.toShortString(), locationId, 0);
  out.endElement();
} else {

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

out.startElement(resultMap, Untyped.getInstance(), ExplicitLocation.UNKNOWN_LOCATION, 0);
  out.startContent();
  out.characters(item.toShortString(), locationId, 0);
  out.endElement();
} else if (item instanceof ArrayItem) {
  out.startElement(resultArray, Untyped.getInstance(), ExplicitLocation.UNKNOWN_LOCATION, 0);
  out.startContent();
  out.characters(item.toShortString(), locationId, 0);
  out.endElement();
} else {

代码示例来源:origin: net.sf.saxon/Saxon-HE

iterator.close();
if (first instanceof ArrayItem) {
  ebvError("a sequence starting with an array item (" + first.toShortString() + ")");
  return false;
} else if (first instanceof MapItem) {
  ebvError("a sequence starting with a map (" + first.toShortString() + ")");
  return false;
} else {
  ebvError("a sequence starting with a function (" + first.toShortString() + ")");
  return false;

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

iterator.close();
if (first instanceof ArrayItem) {
  ebvError("a sequence starting with an array item (" + first.toShortString() + ")");
  return false;
} else if (first instanceof MapItem) {
  ebvError("a sequence starting with a map (" + first.toShortString() + ")");
  return false;
} else {
  ebvError("a sequence starting with a function (" + first.toShortString() + ")");
  return false;

代码示例来源:origin: net.sf.saxon/Saxon-HE

} else if (((Function)i).isMap()) {
  XPathException err = new XPathException(
      expandMessage("Cannot atomize a map (" + i.toShortString() + ")"), "FOTY0013");
  err.setIsTypeError(true);
  err.setLocation(getLocation());

代码示例来源:origin: net.sf.saxon/Saxon-HE

path = Navigator.getPath((NodeInfo) item);
} else {
  path = item.toShortString();

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

path = Navigator.getPath((NodeInfo) item);
} else {
  path = item.toShortString();

代码示例来源:origin: net.sf.saxon/Saxon-HE

XPathException exception = new XPathException(
      "An item on the LHS of the '?' operator is an array, but a value on the RHS of the operator (" +
          baseItem.toShortString() + ") is not an integer", "XPTY0004");
  exception.setIsTypeError(true);
  exception.setLocation(getLocation());
XPathException exception = new XPathException(
    "An item on the LHS of the '?' operator is an external object, but a value on the RHS of the operator (" +
        baseItem.toShortString() + ") is not a singleton string", "XPTY0004");
exception.setIsTypeError(true);
exception.setLocation(getLocation());

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

XPathException exception = new XPathException(
      "An item on the LHS of the '?' operator is an array, but a value on the RHS of the operator (" +
          baseItem.toShortString() + ") is not an integer", "XPTY0004");
  exception.setIsTypeError(true);
  exception.setLocation(getLocation());
XPathException exception = new XPathException(
    "An item on the LHS of the '?' operator is an external object, but a value on the RHS of the operator (" +
        baseItem.toShortString() + ") is not a singleton string", "XPTY0004");
exception.setIsTypeError(true);
exception.setLocation(getLocation());

相关文章