Package org.exolab.castor.builder.info

Examples of org.exolab.castor.builder.info.FieldInfo


     * Tests if getFields returns a list of {@link JDOFieldInfoNature}s.
     */
    public void testGetElementFieldsWithMoreThanOneField() {
        ClassInfo classInfo = new ClassInfo(new JClass("test"));
        FieldInfoFactory factory = new FieldInfoFactory();
        FieldInfo isbn = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "isbn");
        FieldInfo title = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "title");
        isbn.addNature(JDOFieldInfoNature.class.getName());
        title.addNature(JDOFieldInfoNature.class.getName());
        JDOFieldInfoNature jdoIsbn = new JDOFieldInfoNature(isbn);
        JDOFieldInfoNature jdoTitle = new JDOFieldInfoNature(title);
        jdoIsbn.setColumnName("isbn");
        jdoIsbn.setColumnType("integer");
        jdoTitle.setColumnName("title");
View Full Code Here


     * JDOFieldInfoNature.
     */
    public void testGetElementFieldsWithoutNatures() {
        ClassInfo classInfo = new ClassInfo(new JClass("test"));
        FieldInfoFactory factory = new FieldInfoFactory();
        FieldInfo field = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "isbn");
        classInfo.addFieldInfo(field);
        classInfo.addNature(JDOClassInfoNature.class.getName());
        JDOClassInfoNature jdo = new JDOClassInfoNature(classInfo);

View Full Code Here

     * Tests if getFields returns a list of {@link JDOFieldInfoNature}s.
     */
    public void testGetElementFieldsOnlyOneHasNature() {
        ClassInfo classInfo = new ClassInfo(new JClass("test"));
        FieldInfoFactory factory = new FieldInfoFactory();
        FieldInfo field = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "isbn");
        FieldInfo field2 = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "abc");
        field.addNature(JDOFieldInfoNature.class.getName());
        JDOFieldInfoNature jdoField = new JDOFieldInfoNature(field);
        jdoField.setColumnName("isbn");
        jdoField.setColumnType("integer");
View Full Code Here

     */
    public void testGetAttributeTextElementFields() {
        ClassInfo classInfo = new ClassInfo(new JClass("test"));
        FieldInfoFactory factory = new FieldInfoFactory();
       
        FieldInfo elementField = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "isbn");
        // Set node type
        elementField.addNature(XMLInfoNature.class.getName());
        new XMLInfoNature(elementField).setNodeType(NodeType.ELEMENT);
        // Set column name
        elementField.addNature(JDOFieldInfoNature.class.getName());
        JDOFieldInfoNature jdoField = new JDOFieldInfoNature(elementField);
        jdoField.setColumnName("isbn");
        classInfo.addFieldInfo(elementField);
       
        FieldInfo attributeField = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "title");
        // Set node type
        attributeField.addNature(XMLInfoNature.class.getName());
        new XMLInfoNature(attributeField).setNodeType(NodeType.ATTRIBUTE);
        // Set column name
        attributeField.addNature(JDOFieldInfoNature.class.getName());
        jdoField = new JDOFieldInfoNature(attributeField);
        jdoField.setColumnName("title");
        classInfo.addFieldInfo(attributeField);
       
        FieldInfo textField = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "price");
        // Set node type
        textField.addNature(XMLInfoNature.class.getName());
        new XMLInfoNature(textField).setNodeType(NodeType.TEXT);
        // Set column name
        textField.addNature(JDOFieldInfoNature.class.getName());
        jdoField = new JDOFieldInfoNature(textField);
        jdoField.setColumnName("price");
        classInfo.addFieldInfo(textField);
       
        // Add JDO Nature to ClassInfo.
View Full Code Here

        }

        XSType xsType    = new XSClass(SGTypes.OBJECT, "any");
        String vName     = "_anyObject";
        String xmlName   = null;
        FieldInfo result = null;

        if (any.getMaxOccurs() > 1 || any.getMaxOccurs() < 0) {
            result = this.getInfoFactory().createCollection(xsType, vName, "anyObject", getJavaNaming(), useJava50);
            XSListType xsList = ((CollectionInfo) result).getXSList();
            xsList.setMinimumSize(any.getMinOccurs());
            xsList.setMaximumSize(any.getMaxOccurs());
        } else {
            result = this.getInfoFactory().createFieldInfo(xsType, vName);
        }

        if (result.hasNature(XMLInfoNature.class.getName())) {
            XMLInfoNature xmlNature = new XMLInfoNature(result);
           
            if (any.getMinOccurs() > 0) {
                xmlNature.setRequired(true);
            } else {
View Full Code Here

     * @return the new FieldInfo
     */
    public FieldInfo createFieldInfoForChoiceValue() {
        String fieldName = "_choiceValue";
        XSType xsType = new XSClass(SGTypes.OBJECT, "any");
        FieldInfo fInfo = null;
        fInfo = this.getInfoFactory().createFieldInfo(xsType, fieldName);
        fInfo.setComment("Internal choice value storage");
        fInfo.setTransient(true);
        fInfo.setMethods(FieldInfo.READ_METHOD);
       
        if (fInfo.hasNature(XMLInfoNature.class.getName())) {
            XMLInfoNature xmlNature = new XMLInfoNature(fInfo);
           
            xmlNature.setNodeType(NodeType.ELEMENT);
            xmlNature.setRequired(false);
            xmlNature.setNodeName("##any");
View Full Code Here

            final XSType xsType, final boolean useJava50) {
        String fieldName = "_content"; //new xsType()???
        if (component.getContentMemberName() != null) {
            fieldName = component.getContentMemberName();
        }
        FieldInfo fInfo = null;
        if (xsType.isCollection()) {
            fInfo = this.getInfoFactory().createCollection(
                    ((XSListType) xsType).getContentType(), fieldName, null, getJavaNaming(), useJava50);
        } else {
            fInfo = this.getInfoFactory().createFieldInfo(xsType, fieldName);
        }
        fInfo.setComment("internal content storage");
        if (xsType instanceof XSString) {
            fInfo.setDefaultValue("\"\"");
        }
        if (fInfo.hasNature(XMLInfoNature.class.getName())) {
            XMLInfoNature xmlNature = new XMLInfoNature(fInfo);
            xmlNature.setNodeType(NodeType.TEXT);
            xmlNature.setRequired(false);
            xmlNature.setNodeName("#text");
        }
View Full Code Here

                //-- create main group class
                String fname = component.getJavaClassName() + ITEM_NAME;
                fname = getJavaNaming().toJavaMemberName(fname, false);

                FieldInfo fInfo = null;
                if (createForSingleGroup) {
                    //By default a nested group Item can occur only once
                    fInfo = getInfoFactory().createFieldInfo(new XSClass(jClass), fname);
                } else {
                    fInfo = getInfoFactory().createCollection(
                            new XSClass(jClass), "_items", fname, getJavaNaming(), getConfig().useJava50());
                }
                fInfo.setContainer(true);
                String newClassName = className.substring(0, className.length() - 4);
                state = new FactoryState(newClassName, sgState, packageName, component);
                classInfo = state.getClassInfo();
                jClass    = state.getJClass();
                initialize(jClass);
                if (type != null && type.isComplexType()) {
                    ComplexType complexType = (ComplexType) type;
                    if (complexType.isTopLevel() ^ creatingForAnElement) {
                        //process attributes and content type since it has not be performed before
                        Annotated saved = component.getAnnotated();
                        processAttributes(component.getBinding(), complexType, state);
                        component.setView(saved);
                        if (complexType.getContentType() == ContentType.mixed) {
                            FieldInfo fieldInfo = _memberFactory.createFieldInfoForContent(
                                    component, new XSString(), getConfig().useJava50());
                            handleField(fieldInfo, state, component);
                        } else if (complexType.getContentType().getType() == ContentType.SIMPLE) {
                            SimpleContent simpleContent = (SimpleContent) complexType.getContentType();
                            SimpleType temp = simpleContent.getSimpleType();
                            XSType xsType = _typeConversion.convertType(
                                    temp, packageName, getConfig().useJava50());
                            FieldInfo fieldInfo = _memberFactory.createFieldInfoForContent(
                                    component, xsType, getConfig().useJava50());
                            handleField(fieldInfo, state, component);
                            temp = null;
                        } else {
                            // handle multi-valued choice group
View Full Code Here

     *        constructor for
     */
    private void createContructorForDefaultValueForSimpleContent(final Annotated annotated,
                                                                 final ClassInfo classInfo,
                                                                 final SGStateInfo sgStateInfo) {
        FieldInfo textFieldInfo =  classInfo.getTextField();

        boolean generate = false;
        boolean inherited = false;
       
        // check if there is some field inherited from a type
View Full Code Here

                        createSourceCode(component.getBinding(), sType, state.getSGStateInfo());
                    }
                }
            }

            FieldInfo fieldInfo = _memberFactory.createFieldInfo(
                    component, state, getConfig().useJava50());
            handleField(fieldInfo, state, component);
        }
    }
View Full Code Here

TOP

Related Classes of org.exolab.castor.builder.info.FieldInfo

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.