Package org.apache.ws.jaxme.js

Examples of org.apache.ws.jaxme.js.LocalJavaField


    String collectionType = pController.getCollectionType();
    DirectAccessible value;
    if (pValue instanceof DirectAccessible) {
      value = (DirectAccessible) pValue;
    } else {
      LocalJavaField v = pMethod.newJavaField(pController.getRuntimeType());
      v.addLine(pValue);
      value = v;
    }

    LocalJavaField sb = pMethod.newJavaField(StringBuffer.class);
    sb.addLine("new ", StringBuffer.class, "()");
    Object v;
    DirectAccessible loopVar;
    if ("indexed".equals(collectionType)) {
      loopVar = pMethod.addForArray(value);
      v = new Object[]{value, "[", loopVar, "]"};
View Full Code Here


    pMethod.addEndFor();
    return new Object[]{sb, ".toString()"};
  }

  public void forAllNonNullValues(SimpleTypeSG pController, JavaMethod pMethod, Object pValue, SGlet pSGlet) throws SAXException {
    LocalJavaField f = pMethod.newJavaField(LIST_TYPE);
    f.addLine(pValue);
    pMethod.addIf(f, " != null");
    pSGlet.generate(pMethod, f);
    pMethod.addEndIf();
  }
View Full Code Here

            format = new Object[]{"((", JMUnmarshallerImpl.class, ") ", pData,
                            ".getUnmarshaller()).get" + getDatatypeName(), "Format()"};
            mayBeDate = true;
        }
        if (!(pValue instanceof DirectAccessible)) {
            LocalJavaField v = pMethod.newJavaField(String.class);
            v.addLine(pValue);
            pValue = v;
        }
        LocalJavaField pos = pMethod.newJavaField(ParsePosition.class);
        pos.addLine("new ", ParsePosition.class, "(0)");
        LocalJavaField cal = pMethod.newJavaField(mayBeDate ? OBJECT_TYPE : pController.getRuntimeType());
        cal.addLine(format, ".parseObject(", pValue, ", ", pos, ");");
        pMethod.addIf(cal, " == null");
        pMethod.addThrowNew(IllegalArgumentException.class,
                      JavaSource.getQuoted("Failed to parse dateTime "),
                        " + ", pValue, " + ", JavaSource.getQuoted(" at: "),
              " + ", pValue, ".substring(", pos, ".getErrorIndex())");
        pMethod.addEndIf();
        if (mayBeDate) {
            LocalJavaField result = pMethod.newJavaField(pController.getRuntimeType());
            pMethod.addIf(cal, " instanceof ", Calendar.class);
            pMethod.addLine(result, " = (", Calendar.class, ") ", cal, ";");
            pMethod.addElse();
            pMethod.addLine(result, " = ", Calendar.class, ".getInstance();");
            pMethod.addLine(result, ".setTime((", Date.class, ") ", cal, ");");
View Full Code Here

            return cal;
        }
    }

  public void forAllNonNullValues(SimpleTypeSG pController, JavaMethod pMethod, Object pValue, SGlet pSGlet) throws SAXException {
    LocalJavaField f = pMethod.newJavaField(CALENDAR_TYPE);
    f.addLine(pValue);
    pMethod.addIf(f, " != null");
    pSGlet.generate(pMethod, pValue);
    pMethod.addEndIf();
  }
View Full Code Here

      throw new LocSAXException("Failed to convert string value to BigInteger: " + pValue, getLocator());
    }
  }

  public void forAllNonNullValues(SimpleTypeSG pController, JavaMethod pMethod, Object pValue, SGlet pSGlet) throws SAXException {
    LocalJavaField f = pMethod.newJavaField(DECIMAL_TYPE);
    f.addLine(pValue);
    pMethod.addIf(f, " != null");
    pSGlet.generate(pMethod, pValue);
    pMethod.addEndIf();
  }
View Full Code Here

  public Object getCastToString(SimpleTypeSG pController, Object pValue, DirectAccessible pData) {
    return pValue;
  }

  public void forAllNonNullValues(SimpleTypeSG pController, JavaMethod pMethod, Object pValue, SGlet pSGlet) throws SAXException {
    LocalJavaField f = pMethod.newJavaField(STRING_TYPE);
    f.addLine(pValue);
    pMethod.addIf(f, " != null");
    pSGlet.generate(pMethod, pValue);
    pMethod.addEndIf();
  }
View Full Code Here

      String namespaces = pController.getXMLFieldName() + "Namespaces";
      JavaField jf = pSource.newJavaField(namespaces, Set.class);
      jf.setStatic(true);
      jf.setFinal(true);
      JavaClassInitializer jci = pSource.newJavaClassInitializer();
      LocalJavaField set = jci.newJavaField(Set.class);
      set.addLine("new ", HashSet.class, "()");
      XsAnyURI[] uris = namespaceList.getUris();
      for (int i = 0;  i < uris.length;  i++) {
          jci.addLine(set, ".add(", JavaSource.getQuoted(uris[i].toString()), ");");
      }
      if (namespaceList.isLocalSet()) {
View Full Code Here

  public JavaMethod getXMLGetArrayMethod(PropertySG pController, JavaSource pSource) throws SAXException {
      JavaMethod jm = pSource.newJavaMethod(pController.getXMLGetMethodName() + "Array", WildcardAttribute[].class, JavaSource.PUBLIC);
      JavaComment jc = jm.newComment();
      jc.addLine("<p>Returns the array of 'anyAttributes'.</p>");
      LocalJavaField size = jm.newJavaField(int.class);
      size.addLine(pController.getXMLFieldName(), ".size()");
      LocalJavaField result = jm.newJavaField(jm.getType());
      result.addLine("new ", WildcardAttribute.class, "[", size, "]");
      DirectAccessible iter = jm.addForCollection(new Object[]{pController.getXMLFieldName(), ".entrySet()"});
      LocalJavaField entry = jm.newJavaField(Map.Entry.class);
      entry.addLine("(", Map.Entry.class, ") ", iter, ".next()");
      if (!pSource.isInterface()) {
        jm.addLine(result, "[--", size, "] = new ", WildcardAttribute.class, "((",
                   QName.class, ") ", entry, ".getKey(), (", String.class, ") ",
             entry, ".getValue());");
        jm.addEndFor();
View Full Code Here

      JavaMethod jm = pSource.newJavaMethod("marshalChilds", void.class, JavaSource.PUBLIC);
      jm.addThrows(SAXException.class);
      Parameter pData = jm.addParam(JMXmlSerializer.Data.class, "pData");
      Parameter pElement = jm.addParam(Object.class, "pElement");
      JavaQName elementInterface = pController.getClassContext().getXMLInterfaceName();
      LocalJavaField element = jm.newJavaField(elementInterface);
      element.addLine("(", elementInterface, ") ", pElement);
      LocalJavaField chars = jm.newJavaField(String.class);
      SimpleContentSG simpleContent = pController.getSimpleContentSG();
      Object value = simpleContent.getPropertySG().getValue(element);
      chars.addLine(simpleContent.getContentTypeSG().getSimpleTypeSG().getCastToString(jm, value, pData));
        jm.addIf(chars, ".length() > 0");
      LocalJavaField charArray = jm.newJavaField(char[].class);
      charArray.addLine(chars, ".toCharArray()");
      jm.addLine(pData, ".getContentHandler().characters(", charArray, ", 0, ", charArray, ".length);");
        jm.addEndIf();
      return jm;
  }
View Full Code Here

    jm.addIf(pURI, " == null");
    jm.addLine(pURI, " = \"\";");
    jm.addEndIf();
   
    JavaQName resultType = pController.getClassContext().getXMLInterfaceName();
    LocalJavaField result = jm.newJavaField(resultType);
    result.addLine("(", resultType, ") getResult()");

    Set uris = createSetOfExplicitURIs(myAttributes);
    boolean first = true;
    for (Iterator iter = uris.iterator();  iter.hasNext()) {
      String uri = (String) iter.next();
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.js.LocalJavaField

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.