org.apache.abdera.model.Element类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(299)

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

Element介绍

[英]Root interface for all elements in the Feed Object Model
[中]提要对象模型中所有元素的根接口

代码示例

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

public QName getQName() {
  return internal.getQName();
}

代码示例来源:origin: com.atlassian.streams/streams-testing

@Override
protected boolean matchesSafely(Element element, Description mismatchDescription)
{
  if (!matcher.matches(element.getText()))
  {
    mismatchDescription.appendText("title ");
    matcher.describeMismatch(element.getText(), mismatchDescription);
    return false;
  }
  return true;
}

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

public String getAttributeValue(String name) {
  return internal.getAttributeValue(name);
}

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

public StreamBuilder writeElementText(String value) {
 if (!(current instanceof Element)) throw new IllegalStateException("Not currently an element");
 Element element = (Element) current;
 String text = element.getText();
 element.setText(text + value);
 return this;
}

代码示例来源:origin: org.apache.abdera/abdera-extensions-main

/**
 * Set the value of dir attribute
 */
public static <T extends Element> void setDirection(Direction direction, T element) {
  if (direction != Direction.UNSPECIFIED)
    element.setAttributeValue(DIR, direction.toString().toLowerCase());
  else if (direction == Direction.UNSPECIFIED)
    element.setAttributeValue(DIR, "");
  else if (direction == null)
    element.removeAttribute(DIR);
}

代码示例来源:origin: org.apache.abdera/abdera-extensions-main

private static <T extends Element> boolean hasDirection(T element) {
    String dir = element.getAttributeValue("dir");
    if (dir != null && dir.length() > 0)
      return true;
    else if (dir == null) {
      // if the direction is unspecified on this element,
      // let's see if we've inherited it
      Base parent = element.getParentElement();
      if (parent != null && parent instanceof Element)
        return hasDirection((Element)parent);
    }
    return false;
  }
}

代码示例来源:origin: org.apache.abdera/abdera-extensions-json

private static void writeElement(Element child, QName parentqname, JSONStream jstream) throws IOException {
  QName childqname = child.getQName();
  String prefix = childqname.getPrefix();
  jstream.startObject();
  jstream.writeField("name", getName(childqname));
  jstream.writeField("attributes");
  List<QName> attributes = child.getAttributes();
  jstream.startObject();
  if (!isSameNamespace(childqname, parentqname)) {
    jstream.writeField("xml:base", child.getResolvedBaseUri());
  writeLanguageFields(child, jstream);
  for (QName attr : attributes) {
    jstream.writeField(name);
    if ("".equals(attr.getPrefix()) || "xml".equals(attr.getPrefix())) {
      String val = child.getAttributeValue(attr);
      if (val != null && ("href".equalsIgnoreCase(name) || "src".equalsIgnoreCase(name) || "action"
        .equalsIgnoreCase(name))) {
        IRI base = child.getResolvedBaseUri();
        if (base != null)
          val = base.resolve(val).toASCIIString();
      jstream.endObject();
      jstream.writeField("value");
      jstream.writeQuoted(child.getAttributeValue(attr));
      jstream.endObject();

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

public <T extends Element>T setText(String text) {
 internal.setText(text);
 return (T)this;
}

代码示例来源:origin: org.apache.ws.commons.axiom/fom-testsuite

@Override
  protected void runTest() throws Throwable {
    Element element = abdera.getFactory().newElement(new QName("test"));
    element.setAttributeValue(qname, "value");
    assertThat(element.getAttributeValue(qname)).isEqualTo("value");
    List<QName> attrs = element.getAttributes();
    assertThat(attrs).hasSize(1);
    QName actualQName = attrs.get(0);
    assertThat(actualQName).isEqualTo(qname);
    assertThat(actualQName.getPrefix()).isEqualTo(qname.getPrefix());
  }
}

代码示例来源:origin: org.apache.abdera/abdera-extensions-serializer

protected void process(Object source,
            ObjectContext objectContext,
            SerializationContext context,
            Conventions conventions) {
  StreamWriter sw = context.getStreamWriter();
  if (!(source instanceof Element))
    return;
  Element element = (Element)source;
  sw.startElement(element.getQName());
  for (QName attr : element.getAttributes())
    sw.writeAttribute(attr, element.getAttributeValue(attr));
  XPath xpath = context.getAbdera().getXPath();
  List<?> children = xpath.selectNodes("node()", element);
  for (Object child : children) {
    if (child instanceof Element) {
      process(child, new ObjectContext(child), context, conventions);
    } else if (child instanceof Comment) {
      Comment comment = (Comment)child;
      sw.writeComment(comment.getText());
    } else if (child instanceof ProcessingInstruction) {
      ProcessingInstruction pi = (ProcessingInstruction)child;
      sw.writePI(pi.getText(), pi.getTarget());
    } else if (child instanceof TextValue) {
      TextValue tv = (TextValue)child;
      sw.writeElementText(tv.getText());
    }
  }
  sw.endElement();
}

代码示例来源:origin: org.apache.ws.commons.axiom/fom-testsuite

@Override
  protected void runTest() throws Throwable {
    Collection collection = abdera.getFactory().newCollection();
    collection.setAccept("image/png", "image/jpeg");
    List<Element> children = collection.getElements();
    assertThat(children).hasSize(2);
    assertThat(children.get(0).getQName()).isEqualTo(Constants.ACCEPT);
    assertThat(children.get(0).getText()).isEqualTo("image/png");
    assertThat(children.get(1).getQName()).isEqualTo(Constants.ACCEPT);
    assertThat(children.get(1).getText()).isEqualTo("image/jpeg");
  }
}

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

public void writeTo(org.apache.abdera.writer.Writer writer, OutputStream out, WriterOptions options)
  throws IOException {
  internal.writeTo(writer, out, options);
}

代码示例来源:origin: org.apache.abdera/abdera-parser

public <T extends Element> Document<T> getDocument() {
  Document<T> document = null;
  if (parent != null) {
    if (parent instanceof Element) {
      document = ((Element)parent).getDocument();
    } else if (parent instanceof Document) {
      document = (Document<T>)parent;
    }
  }
  return document;
}

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

public <T extends Element> T setAttributeValue(QName qname, String value) {
  internal.setAttributeValue(qname, value);
  return (T)this;
}

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

public Object clone() {
 try {
  ElementWrapper wrapper = (ElementWrapper) super.clone();
  wrapper.internal = (Element) internal.clone();
  return wrapper;
 } catch (CloneNotSupportedException e) {
  // won't happen
  return null;
 }
}

代码示例来源:origin: org.apache.abdera/abdera-extensions-main

/**
 * Return the textual content of a child element using the in-scope directionality
 * 
 * @param element The parent element
 * @param child The XML QName of the child element
 * @return The directionally-wrapped text of the child element
 */
public static <T extends Element> String getBidiChildText(T element, QName child) {
  Element el = element.getFirstChild(child);
  return (el != null) ? getBidiText(getDirection(el), el.getText()) : null;
}

代码示例来源:origin: org.apache.abdera/abdera-security

@SuppressWarnings("unchecked")
private <T extends Element> T _sign(T element, SignatureOptions options) throws XMLSecurityException {
  element.setBaseUri(element.getResolvedBaseUri());
  org.w3c.dom.Element dom = fomToDom((Element)element.clone(), options);
  org.w3c.dom.Document domdoc = dom.getOwnerDocument();
  PrivateKey signingKey = options.getSigningKey();
  X509Certificate cert = options.getCertificate();
  PublicKey pkey = options.getPublicKey();
  IRI baseUri = element.getResolvedBaseUri();
  XMLSignature sig =
    new XMLSignature(domdoc, (baseUri != null) ? baseUri.toString() : "", options.getSigningAlgorithm());

代码示例来源:origin: org.apache.ws.commons.axiom/fom-testsuite

@Override
  protected void runTest() throws Throwable {
    Element element = abdera.getFactory().newElement(new QName("test"));
    QName qname = new QName("urn:test", "attr", "p");
    element.setAttributeValue(qname, "value");
    assertThat(element.getAttributes()).containsExactly(qname);
    element.setAttributeValue(qname, null);
    assertThat(element.getAttributes()).isEmpty();
  }
}

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

public <T extends Element> List<T> getElements() {
  return internal.getElements();
}

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

public List<QName> getAttributes() {
 return internal.getAttributes();
}

相关文章