org.apache.axiom.om.OMElement.getLineNumber()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(65)

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

OMElement.getLineNumber介绍

暂无

代码示例

代码示例来源:origin: deegree/deegree3

/**
 * @param origin
 * @param erroneousElement
 */
XMLErrorPosition( XMLAdapter origin, OMElement erroneousElement ) {
  systemId = origin.getSystemId() == null ? "" : origin.getSystemId().toString();
  lineNumber = erroneousElement == null ? -1 : erroneousElement.getLineNumber();
  // no column number or character offset information available
  columnNumber = -1;
  characterOffset = -1;
}

代码示例来源:origin: org.paxml/PaxmlCore

/**
 * Enclose a tag with <value> as parent tag name.
 * 
 * @param container
 *            the tag's parent tag.
 * @param ele
 *            the tag, null to enclose nothing but only the text.
 * @param text
 *            the text to put under the the newly created <value> tag,
 *            null if no text is needed under the <value> tag.
 * @return the enclosing tag, never null. The line number will be the same
 *         as the ele if it is not null, otherwise, the line number will be
 *         the same as the container's. The <value> tag's position
 *         will be the same as the ele's if it is not null, if it is null,
 *         the position will be the last child of the container.
 */
public static OMElement encloseWithValueTag(OMElement container, OMElement ele, String text) {
  OMElement valueEle = createDataTag(Context.DEFAULT_VALUE_NAME, text, ele == null ? container.getLineNumber()
      : ele.getLineNumber());
  if (ele != null) {
    valueEle.addChild(replaceNode(ele, valueEle));
  } else {
    container.addChild(valueEle);
  }
  return valueEle;
}

代码示例来源:origin: org.paxml/paxml-core

/**
 * Enclose a tag with <value> as parent tag name.
 * 
 * @param container
 *            the tag's parent tag.
 * @param ele
 *            the tag, null to enclose nothing but only the text.
 * @param text
 *            the text to put under the the newly created <value> tag,
 *            null if no text is needed under the <value> tag.
 * @return the enclosing tag, never null. The line number will be the same
 *         as the ele if it is not null, otherwise, the line number will be
 *         the same as the container's. The <value> tag's position
 *         will be the same as the ele's if it is not null, if it is null,
 *         the position will be the last child of the container.
 */
public static OMElement encloseWithValueTag(OMElement container, OMElement ele, String text) {
  OMElement valueEle = createDataTag(Context.DEFAULT_VALUE_NAME, text, ele == null ? container.getLineNumber() : ele.getLineNumber());
  if (ele != null) {
    valueEle.addChild(replaceNode(ele, valueEle));
  } else {
    container.addChild(valueEle);
  }
  return valueEle;
}

代码示例来源:origin: org.paxml/paxml-core

static void processExpressions(ITag tag, IParserContext context) {
  if (!(tag instanceof ExpressionTag)) {
    // make sure all text nodes are converted to <expression> tags
    OMElement ele = context.getElement();
    for (OMNode child : AxiomUtils.getNodes(ele)) {
      if (child.getType() == OMNode.TEXT_NODE) {
        OMText textNode = (OMText) child;
        String text = textNode.getText();
        if (StringUtils.isNotBlank(text)) {
          OMElement expTag = createExpressionTag(text, ele.getLineNumber());
          child.insertSiblingAfter(expTag);
          child.detach();
        }
      }
    }
  }
}

代码示例来源:origin: org.paxml/PaxmlCore

static void processExpressions(ITag tag, IParserContext context) {
  if (!(tag instanceof ExpressionTag)) {
    // make sure all text nodes are converted to <expression> tags
    OMElement ele = context.getElement();
    for (OMNode child : AxiomUtils.getNodes(ele)) {
      if (child.getType() == OMNode.TEXT_NODE) {
        OMText textNode = (OMText) child;
        String text = textNode.getText();
        if (StringUtils.isNotBlank(text)) {
          OMElement expTag = createExpressionTag(text, ele.getLineNumber());
          child.insertSiblingAfter(expTag);
          child.detach();
        }
      }
    }
  }
}

代码示例来源:origin: org.paxml/PaxmlCore

public void visit(OMElement ele, String name, String value) {
  if (filter == null || filter.accept(ele, name, value)) {
    OMElement constEle = createDataTag(name, value, ele.getLineNumber());
    if (firstPushedSub == null) {
      OMNode firstChild = ele.getFirstOMChild();
      if (firstChild != null) {
        firstChild.insertSiblingBefore(constEle);
      } else {
        ele.addChild(constEle);
      }
      firstPushedSub = constEle;
    } else {
      firstPushedSub.insertSiblingAfter(constEle);
    }
  }
}

代码示例来源:origin: org.paxml/paxml-core

public void visit(OMElement ele, String name, String value) {
  if (filter == null || filter.accept(ele, name, value)) {
    OMElement constEle = createDataTag(name, value, ele.getLineNumber());
    if (firstPushedSub == null) {
      OMNode firstChild = ele.getFirstOMChild();
      if (firstChild != null) {
        firstChild.insertSiblingBefore(constEle);
      } else {
        ele.addChild(constEle);
      }
      firstPushedSub = constEle;
    } else {
      firstPushedSub.insertSiblingAfter(constEle);
    }
  }
}

代码示例来源:origin: org.paxml/paxml-core

entity.setLineNumber(root.getLineNumber());
entity.setResource(resource);
entity.setEntity(entity);
IParserContext deepest = contextImpl.getParserStack().getFirst();
OMElement ele = deepest.getElement();
throw new PaxmlParseException("Cannot parse tag <" + ele.getLocalName() + "> at line: " + ele.getLineNumber() + ", resource: " + deepest.getResource()
    + "\r\nBecause: " + Paxml.getCause(e), e);

代码示例来源:origin: org.paxml/PaxmlCore

entity.setLineNumber(root.getLineNumber());
entity.setResource(resource);
entity.setEntity(entity);
OMElement ele = deepest.getElement();
throw new PaxmlParseException(
    "Cannot parse tag <" + ele.getLocalName() + "> at line: " + ele.getLineNumber() + ", resource: "
        + deepest.getResource() + "\r\nBecause: " + Paxml.getCause(e), e);

代码示例来源:origin: org.paxml/PaxmlCore

/**
 * {@inheritDoc}
 */
public TagCreationResult<T> create(Class<? extends T> impl, IParserContext context) {
  T tag = constructObject(impl, context);
  tag.setTagName(context.getElement().getLocalName());
  tag.setLineNumber(context.getElement().getLineNumber());
  tag.setResource(context.getResource());
  tag.setEntity(context.getEntity());
  tag.setParent(context.getParentTag());
  context.getParentTag().addChild(tag);
  
  if (tag instanceof AbstractTag) {
    ((AbstractTag) tag).setFactory(this);
    ((AbstractTag) tag).setXmlElement(context.getElement());
  }
  final boolean childrenParsed = populate(tag, context);
  return new TagCreationResult<T>(tag, childrenParsed);
}

代码示例来源:origin: org.paxml/paxml-core

/**
 * {@inheritDoc}
 */
public TagCreationResult<T> create(Class<? extends T> impl, IParserContext context) {
  T tag = constructObject(impl, context);
  tag.setTagName(context.getElement().getLocalName());
  tag.setLineNumber(context.getElement().getLineNumber());
  tag.setResource(context.getResource());
  tag.setEntity(context.getEntity());
  tag.setParent(context.getParentTag());
  context.getParentTag().addChild(tag);
  if (tag instanceof AbstractTag) {
    ((AbstractTag) tag).setFactory(this);
    ((AbstractTag) tag).setXmlElement(context.getElement());
  }
  final boolean childrenParsed = populate(tag, context);
  return new TagCreationResult<T>(tag, childrenParsed);
}

相关文章

微信公众号

最新文章

更多