Package org.exolab.javasource

Examples of org.exolab.javasource.JClass


     *
     * @param classInfo the XML Schema element declaration
     * @return the JClass representing the MarshalInfo source code
     */
    public JClass createSource(final ClassInfo classInfo) {
        JClass jClass              = classInfo.getJClass();
        String localClassName      = jClass.getLocalName();

        String descriptorClassName = getQualifiedDescriptorClassName(jClass.getName());
        DescriptorJClass classDesc = new DescriptorJClass(_config, descriptorClassName, jClass);

        //-- get handle to default constuctor
        JConstructor cons = classDesc.getConstructor(0);
        JSourceCode jsc   = cons.getSourceCode();
View Full Code Here


     */
    private void addClassDescriptorOverrides(final boolean extended) {
        JSourceCode jsc;

        //-- create getAccessMode method
        JClass amClass = new JClass(MAPPING_ACCESS_MODE);
        JMethod getAccessMode = new JMethod("getAccessMode", amClass,
                                     "the access mode specified for this class.");

        if (_config.useJava50()) {
            getAccessMode.addAnnotation(new JAnnotation(new JAnnotationType("Override")));
View Full Code Here

        // use 'java.lang.Object' instead.
        if (simpleType.getStructureType() == Structure.UNION) {
            return convertUnion(simpleType, packageName, useWrapper, useJava50);
        } else if (base == null) {
            String className = _config.getJavaNaming().toJavaClassName(simpleType.getName());
            return new XSClass(new JClass(className));
        }

        xsType = findXSTypeForEnumeration(simpleType, packageName, javaClassBindingName);
        if (xsType != null) {
            return xsType;
        }

        // If we don't have the XSType yet, we have to look at the Type Code

        switch (base.getTypeCode()) {
            case SimpleTypesFactory.ID_TYPE:             //-- ID
                return new XSId();
            case SimpleTypesFactory.IDREF_TYPE:          //-- IDREF
                return new XSIdRef();
            case SimpleTypesFactory.IDREFS_TYPE:         //-- IDREFS
                return new XSIdRefs(SourceGeneratorConstants.FIELD_INFO_VECTOR, useJava50);
            case SimpleTypesFactory.NMTOKEN_TYPE:        //-- NMTOKEN
                XSNMToken xsNMToken = new XSNMToken();
                xsNMToken.setFacets(simpleType);
                return xsNMToken;
            case SimpleTypesFactory.NMTOKENS_TYPE:       //-- NMTOKENS
                return new XSNMTokens(SourceGeneratorConstants.FIELD_INFO_VECTOR, useJava50);
            case SimpleTypesFactory.ANYURI_TYPE:         //--AnyURI
                return new XSAnyURI();
            case SimpleTypesFactory.BASE64BINARY_TYPE:   //-- base64Bbinary
                return new XSBase64Binary(useJava50);
            case SimpleTypesFactory.HEXBINARY_TYPE:      //-- hexBinary
                return new XSHexBinary(useJava50);
            case SimpleTypesFactory.BOOLEAN_TYPE:        //-- boolean
                return new XSBoolean(useWrapper);
            case SimpleTypesFactory.BYTE_TYPE:           //--byte
                XSByte xsByte = new XSByte(useWrapper);
                if (!simpleType.isBuiltInType()) {
                    xsByte.setFacets(simpleType);
                }
                return xsByte;
            case SimpleTypesFactory.DATE_TYPE:           //-- date
                XSDate xsDate = new XSDate();
                if (!simpleType.isBuiltInType()) {
                    xsDate.setFacets(simpleType);
                }
                return xsDate;
            case SimpleTypesFactory.DATETIME_TYPE:       //-- dateTime
                XSDateTime xsDateTime = new XSDateTime();
                if (!simpleType.isBuiltInType()) {
                    xsDateTime.setFacets(simpleType);
                }
                return xsDateTime;
            case SimpleTypesFactory.DOUBLE_TYPE:         //-- double
                XSDouble xsDouble = new XSDouble(useWrapper);
                if (!simpleType.isBuiltInType()) {
                    xsDouble.setFacets(simpleType);
                }
                return xsDouble;
            case SimpleTypesFactory.DURATION_TYPE:       //-- duration
                XSDuration xsDuration = new XSDuration();
                if (!simpleType.isBuiltInType()) {
                    xsDuration.setFacets(simpleType);
                }
                return xsDuration;
            case SimpleTypesFactory.DECIMAL_TYPE:        //-- decimal
                XSDecimal xsDecimal = new XSDecimal();
                if (!simpleType.isBuiltInType()) {
                    xsDecimal.setFacets(simpleType);
                }
                return xsDecimal;
            case SimpleTypesFactory.FLOAT_TYPE:          //-- float
                XSFloat xsFloat = new XSFloat(useWrapper);
                if (!simpleType.isBuiltInType()) {
                    xsFloat.setFacets(simpleType);
                }
                return xsFloat;
            case SimpleTypesFactory.GDAY_TYPE:           //--GDay
                XSGDay xsGDay = new XSGDay();
                if (!simpleType.isBuiltInType()) {
                    xsGDay.setFacets(simpleType);
                }
                return xsGDay;
            case SimpleTypesFactory.GMONTHDAY_TYPE:      //--GMonthDay
                XSGMonthDay xsGMonthDay = new XSGMonthDay();
                if (!simpleType.isBuiltInType()) {
                    xsGMonthDay.setFacets(simpleType);
                }
                return xsGMonthDay;
            case SimpleTypesFactory.GMONTH_TYPE:         //--GMonth
                XSGMonth xsGMonth = new XSGMonth();
                if (!simpleType.isBuiltInType()) {
                    xsGMonth.setFacets(simpleType);
                }
                return xsGMonth;
            case SimpleTypesFactory.GYEARMONTH_TYPE:     //--GYearMonth
                XSGYearMonth xsGYearMonth = new XSGYearMonth();
                if (!simpleType.isBuiltInType()) {
                    xsGYearMonth.setFacets(simpleType);
                }
                return xsGYearMonth;
            case SimpleTypesFactory.GYEAR_TYPE:          //--GYear
                XSGYear xsGYear = new XSGYear();
                if (!simpleType.isBuiltInType()) {
                    xsGYear.setFacets(simpleType);
                }
                return xsGYear;
            case SimpleTypesFactory.INTEGER_TYPE:        //-- integer
                XSInteger xsInteger = new XSInteger(useWrapper);
                if (!simpleType.isBuiltInType()) {
                    xsInteger.setFacets(simpleType);
                }
                return xsInteger;
            case SimpleTypesFactory.INT_TYPE:            //-- int
                XSInt xsInt = new XSInt(useWrapper);
                if (!simpleType.isBuiltInType()) {
                    xsInt.setFacets(simpleType);
                }
                return xsInt;
            case SimpleTypesFactory.LANGUAGE_TYPE:       //-- Language
                //-- since we don't actually support this type, yet, we'll simply treat
                //-- it as a string, but warn the user.
                LOG.warn("Warning: Currently, the W3C datatype '" + simpleType.getName()
                        + "' is supported only as a String by Castor Source Generator.");
                return new XSString();
            case SimpleTypesFactory.LONG_TYPE:           //-- long
                XSLong xsLong = new XSLong(useWrapper);
                if (!simpleType.isBuiltInType()) {
                    xsLong.setFacets(simpleType);
                }
                return xsLong;
            case SimpleTypesFactory.NCNAME_TYPE:         //--NCName
                return new XSNCName();
            case SimpleTypesFactory.NON_POSITIVE_INTEGER_TYPE: //-- nonPositiveInteger
                XSNonPositiveInteger xsNPInteger = new XSNonPositiveInteger(useWrapper);
                xsNPInteger.setFacets(simpleType);
                return xsNPInteger;
            case SimpleTypesFactory.NON_NEGATIVE_INTEGER_TYPE: //-- nonNegativeInteger
                XSNonNegativeInteger xsNNInteger = new XSNonNegativeInteger(useWrapper);
                xsNNInteger.setFacets(simpleType);
                return xsNNInteger;
            case SimpleTypesFactory.NEGATIVE_INTEGER_TYPE:     //-- negative-integer
                XSNegativeInteger xsNInteger = new XSNegativeInteger(useWrapper);
                xsNInteger.setFacets(simpleType);
                return xsNInteger;
            case SimpleTypesFactory.UNSIGNED_INT_TYPE:     //-- unsigned-integer
                XSUnsignedInt xsUnsignedInt = new XSUnsignedInt(useWrapper);
                xsUnsignedInt.setFacets(simpleType);
                return xsUnsignedInt;
            case SimpleTypesFactory.UNSIGNED_SHORT_TYPE:     //-- unsigned-short
                XSUnsignedShort xsUnsignedShort = new XSUnsignedShort(useWrapper);
                xsUnsignedShort.setFacets(simpleType);
                return xsUnsignedShort;
            case SimpleTypesFactory.UNSIGNED_BYTE_TYPE:     //-- unsigned-byte
                XSUnsignedByte xsUnsignedByte = new XSUnsignedByte(useWrapper);
                xsUnsignedByte.setFacets(simpleType);
                return xsUnsignedByte;
            case SimpleTypesFactory.UNSIGNED_LONG_TYPE:     //-- unsigned-long
                XSUnsignedLong xsUnsignedLong = new XSUnsignedLong();
                xsUnsignedLong.setFacets(simpleType);
                return xsUnsignedLong;
            case SimpleTypesFactory.NORMALIZEDSTRING_TYPE:     //-- normalizedString
                XSNormalizedString xsNormalString = new XSNormalizedString();
                if (!simpleType.isBuiltInType()) {
                    xsNormalString.setFacets(simpleType);
                }
                return xsNormalString;
            case SimpleTypesFactory.POSITIVE_INTEGER_TYPE:     //-- positive-integer
                XSPositiveInteger xsPInteger = new XSPositiveInteger(useWrapper);
                xsPInteger.setFacets(simpleType);
                return xsPInteger;
            case SimpleTypesFactory.QNAME_TYPE:                //-- QName
                XSQName xsQName = new XSQName();
                xsQName.setFacets(simpleType);
                return xsQName;
            case SimpleTypesFactory.STRING_TYPE:               //-- string
                xsType = findXSTypeForEnumeration(simpleType, packageName, javaClassBindingName);
                if (xsType == null) {
                    // Not an enumerated String type
                    XSString xsString = new XSString();
                    if (!simpleType.isBuiltInType()) {
                        xsString.setFacets(simpleType);
                    }
                    xsType = xsString;
                }
                break;
            case SimpleTypesFactory.SHORT_TYPE:               //-- short
                XSShort xsShort = new XSShort(useWrapper);
                if (!simpleType.isBuiltInType()) {
                    xsShort.setFacets(simpleType);
                }
                return xsShort;
            case SimpleTypesFactory.TIME_TYPE:                //-- time
                XSTime xsTime = new XSTime();
                if (!simpleType.isBuiltInType()) {
                    xsTime.setFacets(simpleType);
                }
                return xsTime;
            case SimpleTypesFactory.TOKEN_TYPE:               //-- token
                //-- since we don't actually support this type, yet, we'll simply treat
                //-- it as a string, but warn the user.
                LOG.warn("Warning: Currently, the W3C datatype 'token'"
                        + " is supported only as a String by Castor Source Generator.");
                XSString xsString = new XSString();
                if (!simpleType.isBuiltInType()) {
                    xsString.setFacets(simpleType);
                }
                return xsString;
            default:                                          //-- error
                String name = simpleType.getName();
                if (name == null || name.length() == 0) {
                    //--we know it is a restriction
                    name = simpleType.getBuiltInBaseType().getName();
                }

                LOG.warn("Warning: The W3C datatype '" + name + "' "
                        + "is not currently supported by Castor Source Generator.");
                String className = _config.getJavaNaming().toJavaClassName(name);
                xsType = new XSClass(new JClass(className));
                break;
        }

        return xsType;
    } //-- convertType
View Full Code Here

        } else if (javaType.equals(TypeNames.STRING)) {
            return new XSString();
        }

        //--no XSType implemented for it we return a XSClass
        return new XSClass(new JClass(javaType));
    }
View Full Code Here

            typePackageName = SourceGeneratorConstants.TYPES_PACKAGE;
        }

        className = typePackageName  + '.' + className;

        xsType = new XSClass(new JClass(className));
        xsType.setAsEnumerated(true);

        return xsType;
    }
View Full Code Here

        // }

        if (enumeration) {
            _jClass = new JEnum(className);
        } else {
            _jClass = new JClass(className);
        }

        // if configured, try automatic class name conflict resolution
        if (_sgState.getSourceGenerator().isAutomaticConflictResolution()) {
            _xmlInfoRegistry = sgState.getSourceGenerator()
View Full Code Here

     */
    boolean processIfNotAlreadyProcessed(final Enumeration<?> classKeys,
                                         final SGStateInfo state) throws IOException {
        while (classKeys.hasMoreElements()) {
            ClassInfo classInfo = state.resolve(classKeys.nextElement());
            JClass jClass = classInfo.getJClass();
            if (!state.processed(jClass)
                    && (inCurrentSchema(state, classInfo)
                            || _sourceGenerator.getGenerateImportedSchemas())) {
                process(jClass, state);
                if (state.getStatusCode() == SGStateInfo.STOP_STATUS) {
View Full Code Here

        checkNameNotReserved(jClass.getName(), state);

        ClassInfo classInfo = state.resolve(jClass);

        //-- Have we already processed a class with this name?
        JClass conflict = state.getProcessed(jClass.getName());
        if (conflict != null && !state.getSuppressNonFatalWarnings()) {
            SGStateInfo stateAfterResolution =
                _conflictStrategy.dealWithClassNameConflict(state, classInfo, conflict);
            return stateAfterResolution.getStatusCode() != SGStateInfo.STOP_STATUS;
        }
View Full Code Here

     *         loaded or found
     */
    private void processClassDescriptor(final JClass jClass, final SGStateInfo state,
                                        final ClassInfo classInfo) throws IOException {
        if (_createDescriptors) {
            JClass desc = _descriptorSourceFactory.createSource(classInfo);
            if (checkAllowPrinting(desc)) {
                updateCDRFile(jClass, desc, state, CDR_FILE);
                desc.setHeader(_header);
                if (_lineSeparator == null) {
                    _lineSeparator = System.getProperty("line.separator");
                }
                _jClassPrinter.printClass(desc, _destDir, _lineSeparator, DEFAULT_HEADER);
            }
View Full Code Here

     */
    private void processJDOClassDescriptor(final JClass jClass, final SGStateInfo state,
            final ClassInfo classInfo) throws IOException {
       
        if (_createJdoDescriptors) {
            JClass desc = _jdoDescriptorSourceFactory.createSource(classInfo);
            if (checkAllowPrinting(desc)) {
                updateCDRFile(jClass, desc, state, JDOConstants.PKG_CDR_LIST_FILE);
                desc.setHeader(_header);
                if (_lineSeparator == null) {
                    _lineSeparator = System.getProperty("line.separator");
                }
                _jClassPrinter.printClass(desc, _destDir, _lineSeparator, DEFAULT_HEADER);
            }
View Full Code Here

TOP

Related Classes of org.exolab.javasource.JClass

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.