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

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


            final SortedSet<ElementType> possible = this.possibleTypesService.types();
            this.modelElementTypes = possible.toArray( new ElementType[ possible.size() ] );

            if( xmlElementBindingAnnotation == null )
            {
                final XmlBinding xmlBindingAnnotation = property.getAnnotation( XmlBinding.class );
               
                if( xmlBindingAnnotation != null && possible.size() == 1 )
                {
                    final String path = xmlBindingAnnotation.path();
                    final int slashIndex = path.lastIndexOf( '/' );
                   
                    if( slashIndex == -1 )
                    {
                        this.xmlElementNames = new QName[] { createQualifiedName( path, xmlNamespaceResolver ) };
View Full Code Here


           
            pathString = xmlElementBindingAnnotation.path();
        }
        else
        {
            final XmlBinding xmlBindingAnnotation = property.definition().getAnnotation( XmlBinding.class );
           
            if( xmlBindingAnnotation != null )
            {
                pathString = xmlBindingAnnotation.path();
            }
            else
            {
                pathString = property.name();
            }
View Full Code Here

            }
        }
       
        if( this.rootElementController == null )
        {
            final XmlBinding xmlBindingAnnotation = modelElementType.getAnnotation( XmlBinding.class );
   
            if( xmlBindingAnnotation != null && xmlBindingAnnotation.path().length() != 0 )
            {
                final XmlPath path = new XmlPath( xmlBindingAnnotation.path(), getXmlNamespaceResolver() );
                final QName qualifiedName = path.getSegment( 0 ).getQualifiedName();
                final String localName = qualifiedName.getLocalPart();
                final String prefix = qualifiedName.getPrefix();
                final String namespace = qualifiedName.getNamespaceURI();
               
View Full Code Here

   
    public static QName createDefaultElementName( final ElementType type )
    {
        QName name = null;
       
        final XmlBinding xmlBindingAnnotation = type.getAnnotation( XmlBinding.class );
        final XmlNamespaceResolver xmlNamespaceResolver = new StandardXmlNamespaceResolver( type );
       
        if( xmlBindingAnnotation != null )
        {
            final XmlPath path = new XmlPath( xmlBindingAnnotation.path(), xmlNamespaceResolver );
           
            if( path.getSegmentCount() == 1 )
            {
                final XmlPath.Segment firstSegment = path.getSegment( 0 );
               
View Full Code Here

       
        for( PropertyDef property : type.properties() )
        {
            String xmlPath = null;
           
            final XmlBinding xmlBindingAnnotation = property.getAnnotation( XmlBinding.class );
           
            if( xmlBindingAnnotation != null )
            {
                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

    {
        final Value<?> property = (Value<?>) property();
        final ValueProperty pdef = property.definition();
        final XmlNamespaceResolver xmlNamespaceResolver = resource().getXmlNamespaceResolver();
       
        final XmlBinding genericBindingAnnotation = pdef.getAnnotation( XmlBinding.class );
       
        if( genericBindingAnnotation != null )
        {
            this.path = new XmlPath( genericBindingAnnotation.path(), xmlNamespaceResolver );
            this.removeNodeOnSetIfNull = true;
        }
        else
        {
            final XmlValueBinding bindingAnnotation = pdef.getAnnotation( XmlValueBinding.class );
View Full Code Here

TOP

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

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.