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

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


        final Element element = property().element();
        final PropertyDef property = property().definition();
       
        try
        {
            final XmlElementBinding xmlElementBindingAnnotation = property.getAnnotation( XmlElementBinding.class );
            final XmlNamespaceResolver xmlNamespaceResolver = ( (XmlResource) element.resource() ).getXmlNamespaceResolver();
           
            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 ) };
                    }
                    else if( slashIndex > 0 && slashIndex < path.length() - 1 )
                    {
                        this.path = new XmlPath( path.substring( 0, slashIndex ), xmlNamespaceResolver );
                        this.xmlElementNames = new QName[] { createQualifiedName( path.substring( slashIndex + 1 ), xmlNamespaceResolver ) };
                    }
                }
               
                if( this.xmlElementNames == null )
                {
                    this.path = new XmlPath( property.name(), ( (XmlResource) element.resource() ).getXmlNamespaceResolver() );
                   
                    this.xmlElementNames = new QName[ this.modelElementTypes.length ];
                   
                    for( int i = 0; i < this.modelElementTypes.length; i++ )
                    {
                        this.xmlElementNames[ i ] = createDefaultElementName( this.modelElementTypes[ i ], xmlNamespaceResolver );
                    }
                }
            }
            else
            {
                if( xmlElementBindingAnnotation.path().length() > 0 )
                {
                    this.path = new XmlPath( xmlElementBindingAnnotation.path(), xmlNamespaceResolver );
                }
               
                final XmlElementBinding.Mapping[] mappings = xmlElementBindingAnnotation.mappings();
                this.xmlElementNames = new QName[ this.modelElementTypes.length ];
               
                for( int i = 0; i < this.modelElementTypes.length; i++ )
                {
                    final ElementType type = this.modelElementTypes[ i ];
View Full Code Here


            throw new IllegalStateException();
        }
       
        String pathString = "";
       
        final XmlElementBinding xmlElementBindingAnnotation = property.definition().getAnnotation( XmlElementBinding.class );
       
        if( xmlElementBindingAnnotation != null )
        {
            if( xmlElementBindingAnnotation.mappings().length > 0 )
            {
                throw new IllegalStateException();
            }
           
            pathString = xmlElementBindingAnnotation.path();
        }
        else
        {
            final XmlBinding xmlBindingAnnotation = property.definition().getAnnotation( XmlBinding.class );
           
View Full Code Here

                }
            }
           
            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
View Full Code Here

TOP

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

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.