Examples of ElementMapping


Examples of com.envoisolutions.sxc.jaxb.model.ElementMapping

                            expectedTypes.put(toClass(property.getType()), mapping);
                        }
                    }

                    if (expectedTypes.size() == 1 && !property.isMixed()) {
                        ElementMapping mapping = property.getElementMappings().iterator().next();

                        // null check for non-nillable elements
                        JBlock block = outerBlock;
                        JConditional nullCond = null;
                        if (!mapping.isNillable() && !propertyType.isPrimitive()) {
                            nullCond = outerBlock._if(outerVar.ne(JExpr._null()));
                            block = nullCond._then();
                        }

                        // add space (' ') separator for XmlList
                        if (property.isXmlList()) {
                            // if (fooFirst) {
                            //    writer.writeCharacters(" ");
                            // }
                            // fooFirst = false;
                            block._if(firstVar.not())._then().add(builder.getXSW().invoke("writeCharacters").arg(" "));
                            block.assign(firstVar, JExpr.FALSE);
                        }

                        // write element
                        writeElement(builder, block, mapping, outerVar, propertyType, mapping.isNillable(), property.isXmlList());

                        // property is required and does not support nill, then an error is reported if the value was null
                        if (property.isRequired() && !mapping.isNillable() && nullCond != null) {
                            nullCond._else().invoke(builder.getWriteContextVar(), "unexpectedNullValue").arg(builder.getWriteObject()).arg(property.getName());
                        }
                    } else {
                        JIfElseBlock conditional = new JIfElseBlock();
                        outerBlock.add(conditional);

                        if (property.isMixed()) {
                            // add instance of check
                            JExpression isInstance = outerVar._instanceof(context.toJClass(String.class));
                            JBlock block = conditional.addCondition(isInstance);

                            // declare item variable
                            JVar itemVar;
                            if (toClass(property.getComponentType()) == String.class) {
                                itemVar = outerVar;
                            } else {
                                String itemName = builder.getWriteVariableManager().createId("string");
                                itemVar = block.decl(context.toJClass(String.class), itemName, JExpr.cast(context.toJClass(String.class), outerVar));
                            }
                            writeSimpleTypeElement(builder, itemVar, String.class, block);
                        }

                        ElementMapping nilMapping = null;
                        for (Map.Entry<Class, ElementMapping> entry : expectedTypes.entrySet()) {
                            Class itemType = entry.getKey();
                            ElementMapping mapping = entry.getValue();

                            if (mapping.isNillable()) {
                                if (nilMapping != null && nilMapping != mapping) {
                                    throw new BuildException("Property " + property + " mappings " + mapping.getXmlName() + " and " + nilMapping + " are both nillable.  Only one mapping may of an property may be nilable");
                                }
                                nilMapping = mapping;
                            }

View Full Code Here

Examples of de.innovationgate.wga.common.beans.csconfig.v1.ElementMapping

      _encoderMappingsModel.remove((EncoderMapping) _tblEncoderMappings.getSelection()[0].getData());
    }
  } 
 
  private void handleAddElementMapping() {
    ElementMapping mapping = new ElementMapping();
    mapping.setName("<name>");
    mapping.setImplementationClass("<implementation class>");
    _elementMappingsModel.add(mapping);
  }
View Full Code Here

Examples of de.innovationgate.wga.common.beans.csconfig.v1.ElementMapping

           
           
            // Add element mappings
            Iterator elementMappings = csConfig.getElementMappings().iterator();
            while (elementMappings.hasNext()) {
                ElementMapping mapping = (ElementMapping) elementMappings.next();
                getLog().info("Adding WebTML element '" + mapping.getName() + "'");
                if (addElementMapping(mapping.getName(), mapping.getImplementationClass(), false)) {
                    info.getEnforcedElementMappings().add(mapping.getName());
                }
            }
           
            // Add media keys
            Iterator mediaKeys = csConfig.getMediaKeys().iterator();
View Full Code Here

Examples of org.apache.commons.betwixt.io.read.ElementMapping

            * @param attributes the <code>Attributes</code> used to match <code>ID/IDREF</code>
            * @return the created bean
            */
            protected Object createBean( String namespace, String name, Attributes attributes ) {
                // todo: recycle element mappings
                ElementMapping mapping = new ElementMapping();
                mapping.setType( beanClass );
                mapping.setNamespace( namespace );
                mapping.setName( name );
                mapping.setAttributes( attributes );
                mapping.setDescriptor( descriptor );
               
                Object newInstance = context.getBeanCreationChain().create( mapping, context );
               
                return newInstance;
            }   
View Full Code Here

Examples of org.apache.commons.betwixt.io.read.ElementMapping

        XMLIntrospector introspector = new XMLIntrospector();
        introspector.register(new InputSource(new StringReader(MAPPING)));
       
       
        ElementDescriptor descriptor = introspector.introspect(Element.class).getElementDescriptor();
        ElementMapping elementMapping = new ElementMapping();
        elementMapping.setAttributes(new AttributesImpl());
        elementMapping.setName("Bogus");
        elementMapping.setDescriptor(descriptor);
        elementMapping.setType(Iterator.class);
        ReadContext readContext = new ReadContext(new BindingConfiguration(), new ReadConfiguration());
       
        assertNull(introspector.getPolymorphicReferenceResolver().resolveType(elementMapping, readContext));
       
        elementMapping.setName("elementA");
        Class resolution = introspector.getPolymorphicReferenceResolver().resolveType(elementMapping, readContext);
        assertEquals("Should resolve to the element about", ElementA.class, resolution);
    }
View Full Code Here

Examples of org.apache.commons.betwixt.io.read.ElementMapping

        XMLIntrospector introspector = new XMLIntrospector();
        introspector.register(new InputSource(new StringReader(MAPPING)));
       
       
        ElementDescriptor descriptor = introspector.introspect(Element.class).getElementDescriptor();
        ElementMapping elementMapping = new ElementMapping();
        elementMapping.setAttributes(new AttributesImpl());
        elementMapping.setName("Bogus");
        elementMapping.setDescriptor(descriptor);
        elementMapping.setType(Iterator.class);
        ReadContext readContext = new ReadContext(new BindingConfiguration(), new ReadConfiguration());
       
        assertNull(introspector.getPolymorphicReferenceResolver().resolveType(elementMapping, readContext));
       
        elementMapping.setName("elementA");
        Class resolution = introspector.getPolymorphicReferenceResolver().resolveType(elementMapping, readContext);
        assertEquals("Should resolve to the element about", ElementA.class, resolution);
    }
View Full Code Here

Examples of org.apache.fop.fo.ElementMapping

     * add the element mapping with the given class name
     */
    public void addElementMapping(String mappingClassName)
    throws IllegalArgumentException {
        try {
            ElementMapping mapping =
                (ElementMapping)Class.forName(mappingClassName).newInstance();
            addElementMapping(mapping);
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException("Could not find "
                                               + mappingClassName);
View Full Code Here

Examples of org.apache.fop.fo.ElementMapping

     * add the element mapping with the given class name
     */
    public void addElementMapping(String mappingClassName)
    throws IllegalArgumentException {
        try {
            ElementMapping mapping =
                (ElementMapping)Class.forName(mappingClassName).newInstance();
            addElementMapping(mapping);
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException("Could not find "
                                               + mappingClassName);
View Full Code Here

Examples of org.apache.fop.fo.ElementMapping

     * add the element mapping with the given class name
     */
    public void addElementMapping(String mappingClassName)
    throws IllegalArgumentException {
        try {
            ElementMapping mapping =
                (ElementMapping)Class.forName(mappingClassName).newInstance();
            addElementMapping(mapping);
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException("Could not find "
                                               + mappingClassName);
View Full Code Here

Examples of org.apache.fop.fo.ElementMapping

     */
    public void addElementMapping(String mappingClassName)
  throws IllegalArgumentException
    {
  try {
            ElementMapping mapping = (ElementMapping) Class.forName(
                     mappingClassName).newInstance();
      addElementMapping(mapping);
  } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException("Could not find " + mappingClassName);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.