Package org.apache.abdera.model

Examples of org.apache.abdera.model.Element


    return this;
  }
 
  @SuppressWarnings("unchecked")
  public <T extends Base> String getMimeType(T base) {
    Element element = base instanceof Element ? (Element)base :
                      base instanceof Document ? ((Document)base).getRoot() :
                      null;
    QName qname = element != null ? element.getQName() : null;
    return element != null && qname != null ? mimetypes.get(qname) : null;
  }
View Full Code Here


   * The code should typically match the HTTP status code; however, certain
   * application scenarios may require the use of a different code
   */
  public Error setCode(int code) {
    if (code > -1) {
      Element element = getExtension(CODE);
      if (element != null) {
        element.setText(Integer.toString(code));
      } else {
        addSimpleExtension(CODE,Integer.toString(code));
      }
    } else {
      Element element = getExtension(CODE);
      if (element != null) element.discard();
    }
    return this;
  }
View Full Code Here

  /**
   * Human-readable, language-sensitive description of the error
   */
  public Error setMessage(String message) {
    if (message != null) {
      Element element = getExtension(MESSAGE);
      if (element != null) {
        element.setText(message);
      } else {
        addSimpleExtension(MESSAGE,message);
      }
    } else {
      Element element = getExtension(MESSAGE);
      if (element != null) element.discard();
    }
    return this;
  }
View Full Code Here

    return this;
  }
 
  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;
  }
View Full Code Here

      factories.add(factory);
    return this;
  }

  public <T extends Base> String getMimeType(T base) {
    Element element = base instanceof Element ? (Element)base : ((Document<?>)base).getRoot();
    String namespace = element.getQName().getNamespaceURI();
    synchronized(factories) {
      for (ExtensionFactory factory : factories) {
        if (factory.handlesNamespace(namespace))
          return factory.getMimeType(base);
      }
View Full Code Here

            reportError("Atom feed can only be created from a collection wrapper", null);
        } else if (!isFeed && isCollection) {
            reportError("Atom entry can only be created from a single object", null);
        }
       
        Element atomElement = null;
        try {
            if (isFeed && !isCollection) {
                atomElement = createFeedFromCollectionWrapper(o);
            } else if (!isFeed && !isCollection) {
                atomElement = createEntryFromObject(o, clazz);
View Full Code Here

        return (T)newExtensionElement(qname, (OMContainer)parent);
    }

    private <T extends Element> T newExtensionElement(QName qname, OMContainer parent) {
        String ns = qname.getNamespaceURI();
        Element el = newExtensionElement(qname, parent, null);
        return (T)((ATOM_NS.equals(ns) || APP_NS.equals(ns)) ? el : factoriesMap.getElementWrapper(el));
    }
View Full Code Here

        // Element element = (parserWrapper == null) ?
        // new FOMExtensibleElement(qname, parent, this) :
        // new FOMExtensibleElement(qname, parent, this, parserWrapper);

        Element element =
            (parserWrapper == null) ? (Element)createElement(qname, parent, this, null)
                : (Element)createElement(qname, parent, (FOMBuilder)parserWrapper);

        return (T)element;
    }
View Full Code Here

        Map<String, String> accept = new HashMap<String, String>();
        Iterator<?> i = getChildrenWithName(ACCEPT);
        if (i == null || !i.hasNext())
            i = getChildrenWithName(PRE_RFC_ACCEPT);
        while (i.hasNext()) {
            Element e = (Element)i.next();
            String t = e.getText();
            if (t != null) {
                if (e.getAttributeValue(ALTERNATE) != null && e.getAttributeValue(ALTERNATE).trim().length() > 0) {
                    accept.put(t.trim(), e.getAttributeValue(ALTERNATE));
                } else {
                    accept.put(t.trim(), null);
                }
            }
        }
View Full Code Here

                for (Map.Entry<String, String> entry : mediaRanges.entrySet()) {
                    if (entry.getKey().equalsIgnoreCase("entry")) {
                        addSimpleExtension(ACCEPT, "application/atom+xml;type=entry");
                    } else {
                        try {
                            Element accept = addSimpleExtension(ACCEPT, new MimeType(entry.getKey()).toString());
                            if (entry.getValue() != null) {
                                accept.setAttributeValue(ALTERNATE, entry.getValue());
                            }
                        } catch (javax.activation.MimeTypeParseException e) {
                            throw new org.apache.abdera.util.MimeTypeParseException(e);
                        }
                    }
View Full Code Here

TOP

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

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.