Package org.geotools.data.efeature

Examples of org.geotools.data.efeature.EFeatureIDFactory


        @Override
        public void notifyChanged(Notification msg) {
            //
            // Get ID factory
            //
            EFeatureIDFactory eIDFactory = eIDFactory();
            //
            // Does this context generate IDs?
            //
            if( !(eIDFactory instanceof EFeatureVoidIDFactory) ) {
                //
                // Is added or removed?
                //
                if( msg.getEventType() == Notification.ADD ) {
                    Object value = msg.getNewValue();
                    if(value instanceof EObject) {
                        //
                        // Implements EFeature?
                        //
                        if(value instanceof EFeature) {
                            //
                            // Cast to EFeature
                            //
                            EFeature eFeature = (EFeature)value;
                            //
                            // ----------------------------------------------------------
                            //  Adapt given EFeature (does nothing if already in context)
                            // ----------------------------------------------------------
                            //  This is a very important step: It's part of the context
                            //  startup problem solution (see EFeatureContextHelper),
                            //  and ensures that context-unaware objects become
                            //  aware of the context they are added to. Without this
                            //  step, EFeature stays context-unaware, preventing
                            //  EFeatureReaders from reading them using a context ID
                            //  known by client code.
                            // ----------------------------------------------------------
                            //
                            eAdapt(eFeature, true);
                            //
                            // Get current ID
                            //
                            String eID = eFeature.getID();
                            //
                            // Resolve unique ID
                            //
                            if( !( eID==null || eID.length()==0 ) ) {
                                eIDFactory.useID(eFeature, eID);
                            } else {
                                eIDFactory.createID(eFeature);
                            }
                           
                        } else if(eIDFactory.creates((EObject)value)) {
                            //
                            // Adapt object directly to context
                            //
                            eStructure().eAdapt((EObject)value);
                        }
                    }
                    else if(value instanceof Resource) {
                        ((Resource)value).eAdapters().add(this);
                    }               
                } else if( msg.getEventType() == Notification.REMOVE ) {
                    Object value = msg.getOldValue();
                    if(value instanceof EObject) {
                        //
                        // Cast to EObject
                        //
                        EObject eObject = (EObject)value;
                        //
                        // ID created for this object?
                        //
                        if(eIDFactory.contains(eObject)) {
                            try {
                               
                                //
                                // This should never fail...
                                //
                                eIDFactory.disposeID(eObject);
                               
                            } catch (IllegalArgumentException e) {
                                //
                                // ... but if it does, log a warning ...
                                //                               
View Full Code Here


        //
        String eSetID = eDelegate.getID();
        //
        // Get ID factory from context
        //
        EFeatureIDFactory eIDFactory = eStructure.eContext().eIDFactory();
        //
        // Set ID as used?
        //
        if(!(eSetID==null || eSetID.length()==0)) {
            //
            // Set ID as used for this delegate
            //
            eIDFactory.useID(eDelegate, eSetID);
        } else {
            //
            // Create new ID for this delegate
            //
            eSetID = eIDFactory.createID(eDelegate);
        }
        //
        // Finished
        //
        return eDelegate;
View Full Code Here

        //
        if(eSetUsage) {
            //
            // Get ID factory
            //
            EFeatureIDFactory eIDFactory = getStructure().eContext().eIDFactory();
            //
            // -------------------------------------------------------
            //  Notify ID usage to factory?
            // -------------------------------------------------------
            //  This is part of the context startup problem solution.
            //  When constructing EFeatures from XMI, the context is
            //  unknown. This comes from the fact that values are
            //  serialized before instances are added to the resource
            //  (context). Therefore, a internal context is used
            //  instead. This internal context should not not create
            //  IDs, since IDs only have meaning in the context that
            //  that they belong. The ID factory in the internal
            //  context does therefore not support creation and
            //  usage of IDs (throws OperationUnsupportedException).
            //
            if(!(eIDFactory instanceof EFeatureVoidIDFactory)) {
                //
                // Tell ID factory of ID usage, a new ID is returned if not unique
                //
                eNewID = eIDFactory.useID(eImpl(),eNewID);           
            }
        }
        //
        // Is ID held by this?
        //
View Full Code Here

TOP

Related Classes of org.geotools.data.efeature.EFeatureIDFactory

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.