Package org.apache.abdera.model

Examples of org.apache.abdera.model.Document


   * Returns the appropriate media type for the given Abdera base
   */
  public static <T extends Base>String getMimeType(T base) {
    String type = null;
    if (base instanceof Document) {
      Document doc = (Document)base;
      MimeType mt = doc.getContentType();
      type = (mt != null) ? mt.toString() : getMimeType(doc.getRoot());
    } else if (base instanceof Element) {
      Element el = (Element)base;
      if (el.getDocument() != null) {
        MimeType mt = el.getDocument().getContentType();
        type = (mt != null) ? mt.toString() : null;
View Full Code Here


    Parser parser = fomfactory.newParser();
    ByteArrayInputStream bais = new ByteArrayInputStream(value.getBytes());
    ParserOptions options = parser.getDefaultParserOptions();
    options.setCharset(getXMLStreamReader().getCharacterEncodingScheme());
    options.setFactory(fomfactory);
    Document doc = parser.parse(bais, baseUri.toString(), options);
    return doc.getRoot();
  }
View Full Code Here

    Encryption enc = absec.getEncryption();
    EncryptionOptions options = enc.getDefaultEncryptionOptions();
    options.setDataEncryptionKey(key);
   
    // Encrypt the document using the generated key
    Document enc_doc = enc.encrypt(entry.getDocument(), options);
   
    assertEquals(
      enc_doc.getRoot().getQName(),
      new QName(
        "http://www.w3.org/2001/04/xmlenc#",
        "EncryptedData"));
   
    // Decrypt the document using the generated key
View Full Code Here

  }
 
  public static void testSection12MissingNamespace() throws Exception {
    //http://feedvalidator.org/testcases/atom/1.2/missing-namespace.xml
    IRI uri = baseURI.resolve("1.2/missing-namespace.xml");
    Document doc = null;
    doc = get(uri);
    assertNotNull(doc);
    assertFalse(doc.getRoot() instanceof Feed);
  }
View Full Code Here

  }
 
  public static void testSection12WrongNamespaceCase() throws Exception {
    //http://feedvalidator.org/testcases/atom/1.2/wrong-namespace-case.xml
    IRI uri = baseURI.resolve("1.2/wrong-namespace-case.xml");
    Document doc = null;
    doc = get(uri);
    assertNotNull(doc);
    assertFalse(doc.getRoot() instanceof Feed);
  }
View Full Code Here

  }

  public static void testSection12WrongNamespace() throws Exception {
    //http://feedvalidator.org/testcases/atom/1.2/wrong-namespace.xml
    IRI uri = baseURI.resolve("1.2/wrong-namespace.xml");
    Document doc = null;
    doc = get(uri);
    assertNotNull(doc);
    assertFalse(doc.getRoot() instanceof Feed);
  }
View Full Code Here

            IRI baseUri = null;
            if (o instanceof OMNode) {
              OMNode node = (OMNode) o;
              OMContainer el = node.getParent();
              if (el instanceof Document) {
                Document doc = (Document) el;
                baseUri = doc.getBaseUri();
              } else if (el instanceof Element) {
                Element element = (Element) el;
                baseUri = element.getBaseUri();
              }
            } else if (o instanceof OMAttribute) {
View Full Code Here

    assertEquals(generator.getText(), Version.APP_NAME);
    assertEquals(generator.getVersion(), Version.VERSION);
    assertEquals(generator.getUri().toString(), Version.URI);
    Div div = factory.newDiv();
    assertNotNull(div);
    Document doc = factory.newDocument();
    assertNotNull(doc);
    Element el = factory.newEmail();
    assertNotNull(el);
    el = factory.newEmail();
    el.setText("a");
View Full Code Here

 
  public void testSourceResult() throws Exception {
    try {
      // Apply an XSLT transform to the entire Feed
      TransformerFactory factory = TransformerFactory.newInstance();
      Document xslt = getParser().parse(FOMTest.class.getResourceAsStream("/test.xslt"));
      AbderaSource xsltSource = new AbderaSource(xslt);
      Transformer transformer = factory.newTransformer(xsltSource);
      Document<Feed> feed = getParser().parse(FOMTest.class.getResourceAsStream("/simple.xml"));
      AbderaSource feedSource = new AbderaSource(feed);
      ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

  }
 
  protected Document domToFom(
    org.w3c.dom.Document dom,
    SecurityOptions options) {
      Document doc = null;
      if (dom != null) {
        try {
          Serializer ser = new XMLSerializer();
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          ser.setOutputByteStream(out);
View Full Code Here

TOP

Related Classes of org.apache.abdera.model.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.