Package org.jdom

Examples of org.jdom.Text


                Element artifactIdElement = rootElement.getChild( "artifactId", namespace );
                int index = rootElement.indexOf( artifactIdElement );

                versionElement = new Element( "version", namespace );
                versionElement.setText( version );
                rootElement.addContent( index + 1, new Text( "\n  " ) );
                rootElement.addContent( index + 2, versionElement );
            }
        }
        else
        {
View Full Code Here


  }

  protected void generateExampleXml(Value value, org.jdom.Element parent) {
    DocumentationExample exampleInfo = value.getAnnotation(DocumentationExample.class);
    if (exampleInfo == null || !exampleInfo.exclude()) {
      parent.setContent(new Text(exampleInfo == null || "##default".equals(exampleInfo.value()) ? "..." : exampleInfo.value()));
    }
  }
View Full Code Here

                TypeDefinition typedef = ((XmlClassType) xmlType).getTypeDefinition();
                for (Attribute attribute : typedef.getAttributes()) {
                  generateExampleXml(attribute, el, defaultNs);
                }
                if (typedef.getValue() != null) {
                  el.addContent(new Text("..."));
                }
                else {
                  el.addContent(new Comment("..."));
                }
              }
              else {
                el.addContent(new Text("..."));
              }
            }

            parent.addContent(el);
          }
          else {
            String namespace = ref.getNamespaceURI();
            String name = ref.getLocalPart();
            String prefix = namespace == null ? null : ((EnunciateFreemarkerModel) FreemarkerModel.get()).getNamespacesToPrefixes().get(namespace);
            Namespace jdomNS;
            if (Namespace.XML_NAMESPACE.getURI().equals(namespace)) {
              jdomNS = Namespace.XML_NAMESPACE;
            }
            else if (namespace == null || "".equals(namespace)) {
              jdomNS = Namespace.NO_NAMESPACE;
            }
            else if (namespace.equals(defaultNs)) {
              jdomNS = Namespace.getNamespace("", namespace);
            }
            else {
              jdomNS = Namespace.getNamespace(prefix, namespace);
            }
            org.jdom.Element el = new org.jdom.Element(name, jdomNS);
            el.addContent(new Text("..."));
            parent.addContent(el);
          }
        }
        if (iterations > 1) {
          parent.addContent(new Comment("...more \"" + (ref == null ? choice.getName() : ref.getLocalPart()) + "\" elements..."));
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

                Element artifactIdElement = rootElement.getChild( "artifactId", namespace );
                int index = rootElement.indexOf( artifactIdElement );

                versionElement = new Element( "version", namespace );
                versionElement.setText( version );
                rootElement.addContent( index + 1, new Text( "\n  " ) );
                rootElement.addContent( index + 2, versionElement );
            }
        }
        else
        {
View Full Code Here

       
        // name
        String name = getName();
        if (name != null) {
            Element nameElement = new Element(Tags.NAME, Service.NAMESPACE);
            Text nameText = new Text(name);
            nameElement.addContent(nameText);
            member.addContent(nameElement);
        }
       
        // handle
        String handle = getHandle();
        if (handle != null) {
            Element handleElement = new Element(Tags.HANDLE, NAMESPACE);
            Text handleText = new Text(handle);
            handleElement.addContent(handleText);
            member.addContent(handleElement);
        }
       
        // permission
        String perm = getPermission();
        if (perm != null) {
            Element permissionElement = new Element(Tags.PERMISSION, NAMESPACE);
            Text permissionText = new Text(perm);
            permissionElement.addContent(permissionText);
            member.addContent(permissionElement);
        }
       
        return doc;
View Full Code Here

       
        // handle (required)
        String handle = getHandle();
        if (handle != null && handle.length() > 0) {
            Element handleElement = new Element(Tags.HANDLE, Service.NAMESPACE);
            Text handleText = new Text(handle);
            handleElement.addContent(handleText);
            weblog.addContent(handleElement);
        }
       
        // name
        String name = getName();
        if (name != null) {
            Element nameElement = new Element(Tags.NAME, Service.NAMESPACE);
            Text nameText = new Text(name);
            nameElement.addContent(nameText);
            weblog.addContent(nameElement);
        }
       
        // description
        String desc = getDescription();
        if (desc != null) {
            Element descElement = new Element(Tags.DESCRIPTION, Service.NAMESPACE);
            Text descText = new Text(desc);
            descElement.addContent(descText);
            weblog.addContent(descElement);
        }
       
        // locale
        Locale locale = getLocale();
        if (locale != null) {
            Element localeElement = new Element(Tags.LOCALE, Service.NAMESPACE);
            Text localeText = new Text(locale.toString());
            localeElement.addContent(localeText);
            weblog.addContent(localeElement);
        }
       
        // timezone
        TimeZone tz = getTimezone();
        if (tz != null) {
            Element tzElement = new Element(Tags.TIMEZONE, Service.NAMESPACE);
            Text tzText = new Text(tz.getID());
            tzElement.addContent(tzText);
            weblog.addContent(tzElement);
        }
       
        // creating user
        String creator = getCreatingUser();
        if (creator != null) {
            Element creatorElement = new Element(Tags.CREATING_USER, Service.NAMESPACE);
            Text creatorText = new Text(creator);
            creatorElement.addContent(creatorText);
            weblog.addContent(creatorElement);
        }
       
        // email address
        String email = getEmailAddress();
        if (email != null) {
            Element emailElement = new Element(Tags.EMAIL_ADDRESS, Service.NAMESPACE);
            Text emailText = new Text(email);
            emailElement.addContent(emailText);
            weblog.addContent(emailElement);
        }
       
        // creation date
        Element dateCreatedElement = new Element(Tags.DATE_CREATED, Service.NAMESPACE);
        Date datedCreated = getDateCreated();
        if (dateCreated != null) {
            Text createdText = new Text(String.valueOf(dateCreated.getTime()));
            dateCreatedElement.addContent(createdText);
            weblog.addContent(dateCreatedElement);
        }
       
        // APP entries URL
        Element appEntriesUrlElement = new Element(Tags.APP_ENTRIES_URL, Service.NAMESPACE);
        String appEntriesUrl = getAppEntriesUrl();
        if (appEntriesUrl != null) {
            Text appEntriesUrlText = new Text(appEntriesUrl);
            appEntriesUrlElement.addContent(appEntriesUrlText);
            weblog.addContent(appEntriesUrlElement);
        }
       
        // APP entries URL
        Element appResourcesUrlElement = new Element(Tags.APP_RESOURCES_URL, Service.NAMESPACE);
        String appResourcesUrl = getAppResourcesUrl();
        if (appResourcesUrl != null) {
            Text appResourcesUrlText = new Text(appResourcesUrl);
            appResourcesUrlElement.addContent(appResourcesUrlText);
            weblog.addContent(appResourcesUrlElement);
        }
       
        // enabled
        Element enabledElement = new Element(Tags.ENABLED, Service.NAMESPACE);
        Boolean enabled = getEnabled();
        if (enabled != null) {
            Text enabledText = new Text(getEnabled().toString());
            enabledElement.addContent(enabledText);
            weblog.addContent(enabledElement);
        }
       
        return doc;
View Full Code Here

       
        // name
        String name = getName();
        if (name != null) {
            Element nameElement = new Element(Tags.NAME, Service.NAMESPACE);
            Text nameText = new Text(name);
            nameElement.addContent(nameText);
            userElement.addContent(nameElement);
        }
       
        // full name
        String fullName = getFullName();
        if (fullName != null) {
            Element fullNameElement = new Element(Tags.FULL_NAME, NAMESPACE);
            Text fullNameText = new Text(fullName);
            fullNameElement.addContent(fullNameText);
            userElement.addContent(fullNameElement);
        }
       
        // password
        String password = getPassword();
        if (password != null) {
            Element passwordElement = new Element(Tags.PASSWORD, NAMESPACE);
            Text passwordText = new Text(password);
            passwordElement.addContent(passwordText);
            userElement.addContent(passwordElement);
        }
       
        // locale
        Locale locale = getLocale();
        if (locale != null) {
            Element localeElement = new Element(Tags.LOCALE, Service.NAMESPACE);
            Text localeText = new Text(getLocale().toString());
            localeElement.addContent(localeText);
            userElement.addContent(localeElement);
        }
       
        // timezone
        TimeZone timezone = getTimezone();
        if (timezone != null) {
            Element timezoneElement = new Element(Tags.TIMEZONE, Service.NAMESPACE);
            Text timezoneText = new Text(timezone.getID());
            timezoneElement.addContent(timezoneText);
            userElement.addContent(timezoneElement);
        }
       
        // email address
        String emailAddress = getEmailAddress();
        if (emailAddress != null) {
            Element emailAddressElement = new Element(Tags.EMAIL_ADDRESS, Service.NAMESPACE);
            Text emailAddressText = new Text(emailAddress);
            emailAddressElement.addContent(emailAddressText);
            userElement.addContent(emailAddressElement);
        }
       
        // creation date
        Date datedCreated = getDateCreated();
        if (dateCreated != null) {
            Element dateCreatedElement = new Element(Tags.DATE_CREATED, Service.NAMESPACE);
            Text dateCreatedText = new Text(String.valueOf(dateCreated.getTime()));
            dateCreatedElement.addContent(dateCreatedText);
            userElement.addContent(dateCreatedElement);
        }
       
        // enabled
        Boolean enabled = getEnabled();
        if (enabled != null) {
            Element enabledElement = new Element(Tags.ENABLED, NAMESPACE);
            Text enabledText = new Text(enabled.toString());
            enabledElement.addContent(enabledText);
            userElement.addContent(enabledElement);
        }
       
        return doc;
View Full Code Here

      Element root = document.getRootElement();

      int index = root.indexOf(localRepository);

      root.addContent(index+1, new Text("\n  "));
      root.addContent(index+2, new Text("\n  "));
      root.addContent(index+3, proxies);

      addProxy(proxies, properties);
    }
  }
View Full Code Here

        {
            // simple text in CDATA section
            final CDATA cdata = new CDATA(text);
            assertEquals("incorrect CDATA text", text, cdata.getText());
            cdata.append(new Text(text));
            assertEquals("incorrect CDATA text", text+text, cdata.getText());
            try {
                cdata.append(new Text(cdataEndText));
                fail("failed to detect CDATA end marker");
            } catch (final IllegalDataException exception) {
            }
        }

        {
            // set it to the empty string
            final CDATA cdata = new CDATA(emptyString);
            assertEquals("incorrect CDATA text", "", cdata.getText());
            cdata.append(new Text(emptyString));
            assertEquals("incorrect CDATA text", "", cdata.getText());
            cdata.append(new Text(text));
            assertEquals("incorrect CDATA text", text, cdata.getText());
            cdata.append(new Text(nullString));
            assertEquals("incorrect CDATA text", text, cdata.getText());
            cdata.append(new Text(specialCharactersText));
            assertEquals("incorrect CDATA text", text + specialCharactersText, cdata.getText());
            cdata.append(new Text(nullString));
            assertEquals("incorrect CDATA text", text + specialCharactersText, cdata.getText());
            cdata.append(new Text(emptyString));
            assertEquals("incorrect CDATA text", text + specialCharactersText, cdata.getText());
            cdata.append(new Text(otherString));
            assertEquals("incorrect CDATA text", text + specialCharactersText + otherString, cdata.getText());
            try {
                cdata.append(new Text(cdataEndText));
                fail("failed to detect CDATA end marker");
            } catch (final IllegalDataException exception) {
            }
        }

        {
            // set it to a another string
            final CDATA cdata = new CDATA(otherString);
            assertEquals("incorrect CDATA text", otherString, cdata.getText());
            cdata.append(new Text(text));
            assertEquals("incorrect CDATA text", otherString + text, cdata.getText());
            cdata.append(new Text(nullString));
            assertEquals("incorrect CDATA text", otherString + text, cdata.getText());
            cdata.append(new Text(specialCharactersText));
            assertEquals("incorrect CDATA text", otherString + text + specialCharactersText, cdata.getText());
            cdata.append(new Text(nullString));
            assertEquals("incorrect CDATA text", otherString + text + specialCharactersText, cdata.getText());
            cdata.append(new Text(emptyString));
            assertEquals("incorrect CDATA text", otherString + text + specialCharactersText, cdata.getText());
            try {
                cdata.append(new Text(cdataEndText));
                fail("failed to detect CDATA end marker");
            } catch (final IllegalDataException exception) {
            }
        }
       
        {
            // set it to the null (after it was set to another string so that we
            // are sure comething has changed)
            final CDATA cdata = new CDATA(nullString);
            assertEquals("incorrect CDATA text", "", cdata.getText());
            cdata.append(new Text(specialCharactersText));
            assertEquals("incorrect CDATA text", specialCharactersText, cdata.getText());
            cdata.append(new Text(nullString));
            assertEquals("incorrect CDATA text", specialCharactersText, cdata.getText());
            cdata.append(new Text(text));
            assertEquals("incorrect CDATA text", specialCharactersText + text, cdata.getText());
            cdata.append(new Text(nullString));
            assertEquals("incorrect CDATA text", specialCharactersText + text, cdata.getText());
            cdata.append(new Text(emptyString));
            assertEquals("incorrect CDATA text", specialCharactersText + text, cdata.getText());
            cdata.append(new Text(otherString));
            assertEquals("incorrect CDATA text", specialCharactersText + text + otherString, cdata.getText());
            try {
                cdata.append(new Text(cdataEndText));
                fail("failed to detect CDATA end marker");
            } catch (final IllegalDataException exception) {
            }
        }

        {
            // set it to the null (after it was set to another string so that we
            // are sure comething has changed)
            final CDATA cdata = new CDATA(null);
            assertEquals("incorrect CDATA text", "", cdata.getText());
            cdata.append((String) null);
            assertEquals("incorrect CDATA text", "", cdata.getText());
            try {
                cdata.append(new Text(cdataEndText));
                fail("failed to detect CDATA end marker");
            } catch (final IllegalDataException exception) {
            }
        }

        {
            // set it to the null (after it was set to another string so that we
            // are sure comething has changed)
            final CDATA cdata = new CDATA(null);
            assertEquals("incorrect CDATA text", "", cdata.getText());
            cdata.append((Text) null);
            assertEquals("incorrect CDATA text", "", cdata.getText());
            try {
                cdata.append(new Text(cdataEndText));
                fail("failed to detect CDATA end marker");
            } catch (final IllegalDataException exception) {
            }
        }

        {
            // set text with some special characters
            final CDATA cdata = new CDATA(specialCharactersText);
            assertEquals("incorrect CDATA text", specialCharactersText, cdata.getText());
            cdata.append(new Text(specialCharactersText));
            assertEquals("incorrect CDATA text", specialCharactersText + specialCharactersText, cdata.getText());
            try {
                cdata.append(new Text(cdataEndText));
                fail("failed to detect CDATA end marker");
            } catch (final IllegalDataException exception) {
            }
        }
       
       
        try {
            // set text with some special characters which sould result into an exception
            final CDATA cdata = new CDATA(specialText);
            assertEquals("incorrect CDATA text", specialText, cdata.getText());
            cdata.append(new Text(specialText));
           
            fail("failed to detect CDATA end marker");
        } catch (final IllegalDataException exception) {
        }
    }
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.