Package org.jdom

Examples of org.jdom.Text


  public Object serialize(Object o, Object context) {
    final Object v = myAccessor.read(o);
    final Object node = myBinding.serialize(v, context);

    return new Text(((Content)node).getValue());
  }
View Full Code Here


      children = ArrayUtil.toObjectArray(childrenList);
    }

    if (children.length == 0) {
      children = new Object[] {new Text(myTagAnnotation.textIfEmpty())};
    }

    Object v = binding.deserialize(accessor.read(o), children);
    Object value = XmlSerializerImpl.convert(v, accessor.getValueClass());
    accessor.write(o, value);
View Full Code Here

  public DateBinding() {
    super(Date.class);
  }

  public Object serialize(Object o, Object context) {
    return new Text(Long.toString(((Date)o).getTime()));
  }
View Full Code Here

  public PrimitiveValueBinding(Class<?> myType) {
    this.myType = myType;
  }

  public Object serialize(Object o, Object context) {
    return new Text(String.valueOf(o));
  }
View Full Code Here

      m.addContent(entry);

      Object kNode = myKeyBinding.serialize(k, entry);

      if (kNode instanceof Text) {
        Text text = (Text)kNode;
        entry.setAttribute(getKeyAttributeValue(), text.getText());
      }
      else {
        if (myMapAnnotation != null && !myMapAnnotation.surroundKeyWithTag()) {
          entry.addContent((Content)kNode);
        }
        else {
          Element key = new Element(getKeyAttributeValue());
          entry.addContent(key);
          key.addContent((Content)kNode);
        }
      }

      Object vNode = myValueBinding.serialize(v, entry);
      if (vNode instanceof Text) {
        Text text = (Text)vNode;
        entry.setAttribute(getValueAttributeName(), text.getText());
      }
      else {
        if (myMapAnnotation != null && !myMapAnnotation.surroundValueWithTag()) {
          entry.addContent((Element)vNode);
        }
View Full Code Here

    if (myAttributeName.length() != 0) {
      e.setAttribute(myAttributeName, value);
    }
    else {
      e.addContent(new Text(value));
    }

    return e;
  }
View Full Code Here

    if (value == null) return targetElement;

    Object node = myBinding.serialize(value, targetElement);
    if (node instanceof Text) {
      Text text = (Text)node;
      targetElement.setAttribute(myValueAttribute, text.getText());
    }
    else {
      if (targetElement != node) {
        JDOMUtil.addContent(targetElement, node);
      }
View Full Code Here

        {
            List l = xHTMLHeadCrosswalk.disseminateList(item);
            StringWriter sw = new StringWriter();

            XMLOutputter xmlo = new XMLOutputter();
            xmlo.output(new Text("\n"), sw);
            for (int i = 0; i < l.size(); i++)
            {
                Element e = (Element) l.get(i);
                // FIXME: we unset the Namespace so it's not printed.
                // This is fairly yucky, but means the same crosswalk should
                // work for Manakin as well as the JSP-based UI.
                e.setNamespace(null);
                xmlo.output(e, sw);
                xmlo.output(new Text("\n"), sw);
            }
            pageMeta.addMetadata("xhtml_head_item").addContent(sw.toString());
        }
        catch (CrosswalkException ce)
        {
View Full Code Here

        {
            List l = xHTMLHeadCrosswalk.disseminateList(item);
            StringWriter sw = new StringWriter();

            XMLOutputter xmlo = new XMLOutputter();
            xmlo.output(new Text("\n"), sw);
            for (int i = 0; i < l.size(); i++)
            {
                Element e = (Element) l.get(i);
                // FIXME: we unset the Namespace so it's not printed.
                // This is fairly yucky, but means the same crosswalk should
                // work for Manakin as well as the JSP-based UI.
                e.setNamespace(null);
                xmlo.output(e, sw);
                xmlo.output(new Text("\n"), sw);
            }
            headMetadata = sw.toString();
        }
        catch (CrosswalkException ce)
        {
View Full Code Here

     * @param element The element to update, must not be <code>null</code>.
     * @param value   The text string to set, must not be <code>null</code>.
     */
    private void rewriteValue( Element element, String value )
    {
        Text text = null;
        if ( element.getContent() != null )
        {
            for ( Iterator<?> it = element.getContent().iterator(); it.hasNext(); )
            {
                Object content = it.next();
                if ( ( content instanceof Text ) && ( (Text) content ).getTextTrim().length() > 0 )
                {
                    text = (Text) content;
                    while ( it.hasNext() )
                    {
                        content = it.next();
                        if ( content instanceof Text )
                        {
                            text.append( (Text) content );
                            it.remove();
                        }
                        else
                        {
                            break;
                        }
                    }
                    break;
                }
            }
        }
        if ( text == null )
        {
            element.addContent( value );
        }
        else
        {
            String chars = text.getText();
            String trimmed = text.getTextTrim();
            int idx = chars.indexOf( trimmed );
            String leadingWhitespace = chars.substring( 0, idx );
            String trailingWhitespace = chars.substring( idx + trimmed.length() );
            text.setText( leadingWhitespace + value + trailingWhitespace );
        }
    }
View Full Code Here

TOP

Related Classes of org.jdom.Text

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.