Package org.eclipse.sapphire.modeling.xml.annotations

Examples of org.eclipse.sapphire.modeling.xml.annotations.XmlValueBinding


                xmlPath = xmlBindingAnnotation.path();
            }

            if( xmlPath == null )
            {
                final XmlValueBinding xmlValueBindingAnnotation = property.getAnnotation( XmlValueBinding.class );
               
                if( xmlValueBindingAnnotation != null )
                {
                    xmlPath = xmlValueBindingAnnotation.path();
                }
            }
           
            if( xmlPath == null )
            {
                final XmlElementBinding xmlElementBindingAnnotation = property.getAnnotation( XmlElementBinding.class );
               
                if( xmlElementBindingAnnotation != null )
                {
                    final int mappingsCount = xmlElementBindingAnnotation.mappings().length;
                   
                    if( mappingsCount == 0 )
                    {
                        xmlPath = xmlElementBindingAnnotation.path();
                    }
                    else if( mappingsCount == 1 )
                    {
                        xmlPath = xmlElementBindingAnnotation.mappings()[ 0 ].element();
                       
                        if( xmlElementBindingAnnotation.path().length() > 0 )
                        {
                            xmlPath = xmlElementBindingAnnotation.path() + "/" + xmlPath;
                        }
                    }
                    else
                    {
                        continue; // todo: report unsupported
                    }
                }
            }
           
            if( xmlPath == null )
            {
                final XmlListBinding xmlListBindingAnnotation = property.getAnnotation( XmlListBinding.class );
               
                if( xmlListBindingAnnotation != null )
                {
                    if( xmlListBindingAnnotation.mappings().length == 1 )
                    {
                        xmlPath = xmlListBindingAnnotation.mappings()[ 0 ].element();
                       
                        if( xmlListBindingAnnotation.path().length() > 0 )
                        {
                            xmlPath = xmlListBindingAnnotation.path() + "/" + xmlPath;
                        }
                    }
                    else
                    {
                        continue; // todo: report unsupported
                    }
                }
            }
           
            if( xmlPath != null )
            {
                properties.put( xmlPath, property );
            }
        }
       
        // Write the summary document fragment
       
        out.println( "<table>" );
        out.println( "  <tr>" );
        out.println( "    <th>Element</th>" );
        out.println( "    <th>Cardinality</th>" );
        out.println( "    <th>Description</th>" );
        out.println( "  </tr>" );
       
        for( Map.Entry<String,PropertyDef> entry : properties.entrySet() )
        {
            final String xmlPath = entry.getKey();
            final PropertyDef property = entry.getValue();
           
            final String cardinality;
           
            if( property instanceof ValueProperty )
            {
                if( property.hasAnnotation( Required.class ) )
                {
                    cardinality = "1";
                }
                else
                {
                    cardinality = "0 or 1";
                }
            }
            else if( property instanceof ElementProperty )
            {
                cardinality = "0 or 1";
            }
            else if( property instanceof ListProperty )
            {
                cardinality = "0 or more";
            }
            else
            {
                throw new IllegalStateException();
            }
           
            out.println( "  <tr>" );

            out.println( td( xmlPath ) );
            out.println( td( cardinality ) );
           
            out.println( "    <td>" );
           
            if( property.hasAnnotation( Documentation.class ) )
            {
                documentation( out, property.getAnnotation( Documentation.class ) );
            }
            else
            {
                out.println( "&nbsp;" );
            }
           
            if( property instanceof ElementProperty || property instanceof ListProperty )
            {
                boolean skip = false;
               
                final ElementType childType = property.service( PossibleTypesService.class ).types().first();
                final SortedSet<PropertyDef> childTypeProperties = childType.properties();
               
                if( childTypeProperties.size() == 1 )
                {
                    final PropertyDef childTypeProperty = childTypeProperties.first();
                   
                    if( childTypeProperty instanceof ValueProperty )
                    {
                        if( childTypeProperty.hasAnnotation( XmlBinding.class ) )
                        {
                            final XmlBinding b = childTypeProperty.getAnnotation( XmlBinding.class );
                           
                            if( b != null && b.path().length() == 0 )
                            {
                                skip = true;
                            }
                        }
                        else if( childTypeProperty.hasAnnotation( XmlValueBinding.class ) )
                        {
                            final XmlValueBinding b = childTypeProperty.getAnnotation( XmlValueBinding.class );
                           
                            if( b != null && b.path().length() == 0 )
                            {
                                skip = true;
                            }
                        }
                    }
View Full Code Here


            this.path = new XmlPath( genericBindingAnnotation.path(), xmlNamespaceResolver );
            this.removeNodeOnSetIfNull = true;
        }
        else
        {
            final XmlValueBinding bindingAnnotation = pdef.getAnnotation( XmlValueBinding.class );
           
            if( bindingAnnotation != null )
            {
                this.path = new XmlPath( bindingAnnotation.path(), xmlNamespaceResolver );
                this.removeNodeOnSetIfNull = bindingAnnotation.removeNodeOnSetIfNull();
               
                if( bindingAnnotation.mapExistanceToValue().length() > 0 )
                {
                    this.treatExistanceAsValue = true;
                   
                    final String directive = bindingAnnotation.mapExistanceToValue();
                    StringBuilder buf = new StringBuilder();
                    boolean escapeNextChar = false;
                    int separatorCount = 0;
                   
                    for( int i = 0, n = directive.length(); i < n; i++ )
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.modeling.xml.annotations.XmlValueBinding

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.