Java 类org.eclipse.emf.ecore.xml.type.AnyType 实例源码

项目:org.lovian.eaxmireader    文件:EAEObjInfoManager.java   
private String findOwnerIdOfEObj(AnyType eObjAnyType) {
    String ownerId = null;
    if (eObjAnyType != null) {
        FeatureMap mixed = eObjAnyType.getMixed();
        for (Entry entry : mixed) {
            String entryName = (entry.getEStructuralFeature()).getName();
            if (entryName != null) {
                if (entryName.equals("model")) {
                    if (entry.getValue() instanceof AnyType) {
                        AnyType modelAnyType = (AnyType) entry.getValue();
                        ownerId = getEObjEOwnerIdFromModelAnyType(modelAnyType);
                        break;
                    }
                }
            }
        }
    }
    return ownerId;
}
项目:org.lovian.eaxmireader    文件:EAEObjInfoManager.java   
private String findStereoTypeOfEObj(AnyType eObjAnyType) {
    // find parameter and store it in List
    String stereoType = null;
    if (eObjAnyType != null) {
        FeatureMap mixed = eObjAnyType.getMixed();
        for (Entry entry : mixed) {
            String entryName = (entry.getEStructuralFeature()).getName();
            if (entryName != null) {
                if (entryName.equals("properties")) {
                    if (entry.getValue() instanceof AnyType) {
                        AnyType propertiesAnyType = (AnyType) entry
                                .getValue();
                        stereoType = getEObjStereotypeFromPropertyAnyType(propertiesAnyType);
                        break;
                    }
                }
            }
        }
    }
    return stereoType;
}
项目:org.lovian.eaxmireader    文件:EAEObjInfoManager.java   
private ArrayList<Parameter> findEObjAllParameterList(AnyType eObjAnyType) {
    // find parameter in 'Tag' tag and store it in List
    ArrayList<Parameter> paramList = null;
    FeatureMap mixed = eObjAnyType.getMixed();
    for (Entry entry : mixed) {
        String entryName = (entry.getEStructuralFeature()).getName();
        if (entryName != null) {
            if (entryName.equals("tags")) {
                if (entry.getValue() instanceof AnyType) {
                    AnyType tagAnyType = (AnyType) entry.getValue();
                    paramList = findTagsAttrAndAddToParamList(tagAnyType);
                }
            }
        }
    }
    return paramList;
}
项目:org.lovian.eaxmireader    文件:EAEObjInfoManager.java   
private String getEObjStereotypeFromPropertyAnyType(
        AnyType propertiesAnyType) {
    String stereoType = null;
    if (propertiesAnyType != null) {
        FeatureMap propertiesMap = propertiesAnyType.getAnyAttribute();
        for (Entry entry : propertiesMap) {
            String entryName = (entry.getEStructuralFeature()).getName();
            if (entryName != null) {
                if (entryName.equals("stereotype")) {
                    stereoType = (String) entry.getValue();
                    break;
                }
            }
        }
    }

    return stereoType;
}
项目:caml2tosca    文件:ToscaUtil.java   
public static FeatureMap.Entry createContainmentFeatureMapEntry(String nsPrefix, String nsURI, String name, Element base, Stereotype refinement) {
    AnyType anyType = XMLTypeFactory.eINSTANCE.createAnyType();

    // create for each property of the refinement an EReference and the SimpleFeatureMapEntry
    for(Property property : refinement.getAllAttributes()) {
        if(!property.getName().startsWith("base_")) {
            AnyType anyTypeForProperty = XMLTypeFactory.eINSTANCE.createAnyType();
            SimpleFeatureMapEntry simpleFeatureMapEntry = new SimpleFeatureMapEntry((EStructuralFeature.Internal) Text_Attribute, getStringRepresentation(base.getValue(refinement, property.getName())));
            anyTypeForProperty.getMixed().add(simpleFeatureMapEntry);

            EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry containmentFeatureMapEntry = 
                    new EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry((EStructuralFeature.Internal) createTEReference(nsPrefix, nsURI, property.getName()), (InternalEObject) anyTypeForProperty);

            anyType.getMixed().add(containmentFeatureMapEntry);
        }
    }

    return new EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry((EStructuralFeature.Internal) createTEReference(nsPrefix, nsURI, name), 
            (InternalEObject) anyType);         
}
项目:caml2tosca    文件:ToscaUtil.java   
public static FeatureMap.Entry createFeatureMapEntryForSlots(String nsPrefix, String nsURI, String name, Collection<Slot> slots) {
    AnyType anyType = XMLTypeFactory.eINSTANCE.createAnyType();

    // create for each property of the refinement an EReference and the SimpleFeatureMapEntry
    for(Slot slot : slots) {
        AnyType anyTypeForProperty = XMLTypeFactory.eINSTANCE.createAnyType();
        // TODO: What about list of values! -> currently we take the first value only
        SimpleFeatureMapEntry simpleFeatureMapEntry = new SimpleFeatureMapEntry((EStructuralFeature.Internal) Text_Attribute, getStringRepresentation(slot.getValues().get(0)));
        anyTypeForProperty.getMixed().add(simpleFeatureMapEntry);

        EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry containmentFeatureMapEntry = 
                new EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry((EStructuralFeature.Internal) createTEReference(nsPrefix, nsURI, slot.getDefiningFeature().getName()), (InternalEObject) anyTypeForProperty);

        anyType.getMixed().add(containmentFeatureMapEntry);
    }

    return new EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry((EStructuralFeature.Internal) createTEReference(nsPrefix, nsURI, name), 
            (InternalEObject) anyType);         
}
项目:clickwatch    文件:AbstractTests.java   
protected void deserialize(String xmlStr, FeatureMap map) {
    xmlStr = EmfXmlUtil.stripProcessingInstructions(xmlStr);
    XMLTypeDocumentRoot xml = (XMLTypeDocumentRoot)EmfXmlUtil.deserializeXml("<xml>" + xmlStr + "</xml>");

    FeatureMap xmlRootMixed = ((AnyType)xml.getMixed().getValue(0)).getMixed();
    if (xmlRootMixed.size() > 0) {
        for(FeatureMap.Entry entry: xmlRootMixed) {
            Object anyValue = entry.getValue();
            if (!(anyValue == null || (anyValue instanceof String && "".equals(((String)anyValue).trim())))) {
                EStructuralFeature anyFeature = entry.getEStructuralFeature();
                if (anyValue instanceof EObject) {
                    anyValue = EcoreUtil.copy((EObject)anyValue);
                }
                map.add(FeatureMapUtil.createRawEntry(anyFeature, anyValue));                       
            }
        }                   
    }
    EcoreUtil.delete(xml, true);
}
项目:clickwatch    文件:CompoundHandlerEventAdapter.java   
private void createHandlerEvents(Object value, Map<String, String> attributes) {        
    // set the timestamp
    long drift = driftMavrSum / driftMavrValues.size();
    long timestamp = 0;
    if (inRecordMode) {
        timestamp = time(attributes.get("time")) + drift;
    } else {
        timestamp = pullTime;
    }

    // set the value
    String recordStr = null;
    for (FeatureMap.Entry valueFme: ((AnyType)value).getMixed()) {
        if (valueFme.getEStructuralFeature().getName().equals("cDATA")) {
            recordStr = (String)valueFme.getValue();
        }
    }
    Handler newHandler;
    if (recordStr != null) {
        newHandler = valueAdapter.create(currentHandlerName, timestamp, recordStr);
    } else {
        newHandler = valueAdapter.create(currentHandlerName, timestamp, "");
    }

    onHandlerReceived(newHandler);
}
项目:org.lovian.eaxmireader    文件:EAEObjInfoManager.java   
public EAEObjInfoManager(Map<EObject, AnyType> eObj2ExtensionMap,
        Map<EObject, String> eObj2IdMap, Map<String, EObject> id2eObjMap) {
    super();
    this.eObj2ExtensionMap = eObj2ExtensionMap;
    this.eObj2IdMap = eObj2IdMap;
    this.id2EObjMap = id2eObjMap;
}
项目:org.lovian.eaxmireader    文件:EAEObjInfoManager.java   
private String getEObjEOwnerIdFromModelAnyType(AnyType modelAnyType) {
    String ownerId = null;
    FeatureMap eObjAttrs = modelAnyType.getAnyAttribute();
    for (Entry entry : eObjAttrs) {
        String entryName = (entry.getEStructuralFeature()).getName();
        if (entryName.equals("owner")) {
            ownerId = (String) entry.getValue();
            break;
        }
    }
    return ownerId;
}
项目:org.lovian.eaxmireader    文件:EAEObjInfoManager.java   
private String getEObjectIdRefFromExtensionImpl(AnyType eObjAnyType) {
    String idRef = null;
    FeatureMap eObjAttrs = eObjAnyType.getAnyAttribute();
    for (Entry entry : eObjAttrs) {
        String entryName = (entry.getEStructuralFeature()).getName();
        if (entryName.equals("idref")) {
            idRef = (String) entry.getValue();
        }
    }
    return idRef;
}
项目:org.lovian.eaxmireader    文件:EAEObjInfoManager.java   
private ArrayList<Constraint> findEObjAllConstraintList(AnyType eObjAnyType) {
    ArrayList<Constraint> constraintList = null;
    FeatureMap mixed = eObjAnyType.getMixed();
    for (Entry entry : mixed) {
        String entryName = (entry.getEStructuralFeature()).getName();
        if (entryName != null) {
            if (entryName.equals("constraints")) {
                AnyType cosntraintsAnyType = (AnyType) entry.getValue();
                constraintList = findConstraintAttrAndAddToConstraintList(cosntraintsAnyType);
            }
        }
    }
    return constraintList;
}
项目:eclipse-avro    文件:XMLTypeResourceImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public AnyType popAnyType(AnyTypeStackFrame anyType)
{
  AnyType resultAnyTypeValue = anyType.popAnyType();
  this.anyType = anyType;
  return resultAnyTypeValue;
}
项目:eclipse-avro    文件:XMLTypeResourceImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected AnyType popAnyType()
{
  pop();
  AnyType resultAnyTypeValue = theAnyType;
  theAnyType = null;
  return resultAnyTypeValue;
}
项目:clickwatch    文件:CopyXPath.java   
private String getXPath(EObject object) {
    if (object == null || object instanceof Resource) {
        return "";
    }

    String prefix = getXPath(object.eContainer());
    if (object instanceof Network) {
        if (object.eContainer() == null || object.eContainer() instanceof Resource) {
            return prefix + "/Network";
        } else {
            return prefix + "/subnetwork[@name='" + ((Network)object).getName() + "']";
        }
    } else if (object instanceof Node) {
        return prefix + "/node[@iNetAddress='" + ((Node)object).getINetAddress() + "']";
    } else if (object instanceof Element) {
        return prefix + "/" + ((Element)object).getName();
    } else if (object instanceof Handler) {
        return prefix + "/" + ((Handler)object).getName();
    } else if (object instanceof AnyType) {
        FeatureMap fm = (FeatureMap)object.eContainer().eGet(object.eContainingFeature());
        for (int i = 0; i < fm.size(); i++) {
            if (fm.getValue(i) == object) {
                return prefix + "/" + fm.getEStructuralFeature(i).getName();
            }
        }
        return "";
    } else {
        return "/";
    }
}
项目:clickwatch    文件:ClickWatchReflectiveItemProviderAdapterFactory.java   
@Override
public String getText(Object object) {
    if (((FeatureMap.Entry)value).getValue() instanceof AnyType) {
        return ((FeatureMap.Entry) value).getEStructuralFeature().getName();
    } else {
        return value.toString();
    }
}
项目:clickwatch    文件:XMLTypeResourceImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public AnyType popAnyType(AnyTypeStackFrame anyType)
{
  AnyType resultAnyTypeValue = anyType.popAnyType();
  this.anyType = anyType;
  return resultAnyTypeValue;
}
项目:clickwatch    文件:XMLTypeResourceImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected AnyType popAnyType()
{
  pop();
  AnyType resultAnyTypeValue = theAnyType;
  theAnyType = null;
  return resultAnyTypeValue;
}
项目:clickwatch    文件:HandlerTargetIdProviderFactory.java   
@Override
public ITargetIdProvider getTargetIdProvider(SourceObjectKey sok) {
    ClickWatchModelPackage clickWatchModel = ClickWatchModelPackage.eINSTANCE;

    if (sok.isRoot()) {
        return new ITargetIdProvider() {                
            @Override
            public TargetId[] provideTargetIds(ITargetIdProviderContext ctx,
                    SourceObjectKey sourceObjectKey) {
                TargetId targetId = new TargetId(null, null, 
                        ClickWatchModelPackage.eINSTANCE.getHandler(), 
                        "", handlerClassName);
                return new TargetId[] { targetId };
            }
        };
    } else if (sok.getObject() instanceof Handler) {
        if (clickWatchModel.getHandler().getEAllStructuralFeatures().contains(sok.getFeature())) {
            return new NullTargetIdProvider();
        } else {
            return new FeatureMapEntryTargetIdProvider(false);
        }
    } else if (sok.getObject() instanceof AnyType) {
        return new FeatureMapEntryTargetIdProvider(false);
    } else {
        Preconditions.checkState(false);
        return null;
    }
}
项目:clickwatch    文件:TestTargetIdProviderFactory.java   
@Override
public ITargetIdProvider getTargetIdProvider(SourceObjectKey sok) {
    TestSourceModelPackage testSourceModel = TestSourceModelPackage.eINSTANCE;

    if (sok.isRoot()) {
        return new CopyTargetIdProvider(false);
    } else if (sok.getObject() instanceof RootClass) {
        if (testSourceModel.getRootClass().getEAllStructuralFeatures().contains(sok.getFeature())) {
            return new CopyTargetIdProvider(false);
        } else {
            return new FeatureMapEntryTargetIdProvider(false);
        }
    } else if (sok.getObject() instanceof ClassWithListFeatures) {
        if (sok.getFeature() == testSourceModel.getClassWithListFeatures_ListFeature1() || 
                sok.getFeature() == testSourceModel.getClassWithListFeatures_ListFeature2()) {
            return new ListTargetIdProvider(false, true, false);
        } else {
            return new CopyTargetIdProvider(false);
        }
    } else if (sok.getObject() instanceof ListFeatureElementClass1) {
        if (sok.getFeature() == testSourceModel.getListFeatureElementClass1_ListFeature3()) {
            return new ListTargetIdProvider(false, true, true);
        } else if (testSourceModel.getListFeatureElementClass1().getEAllStructuralFeatures().contains(sok.getFeature())) {
            return new CopyTargetIdProvider(true);
        } else {
            return new FeatureMapEntryTargetIdProvider(false);              
        }
    } else if (sok.getObject() instanceof ListFeatureElementClass2) {
        return new CopyTargetIdProvider(true);
    } else if (sok.getObject() instanceof ListFeatureElementClass3) {
        return new CopyTargetIdProvider(true);
    } else if (sok.getObject() instanceof AnyType) {
        return new FeatureMapEntryTargetIdProvider(false);
    } else {
        Preconditions.checkState(false);
        return null;
    }
}
项目:clickwatch    文件:LogFileGenerator.java   
private void getLeafs(AnyType any, List<AnyType> result) {
    boolean hasChild = false;
    for (FeatureMap.Entry fme: any.getAny()) {
        Object child = fme.getValue();
        if (child instanceof AnyType) {
            hasChild = true;
            getLeafs((AnyType)child, result);
        }
    }
    if (!hasChild) {
        result.add(any);
    }
}
项目:clickwatch    文件:LogFileBenchmarkAdapter.java   
private void getLeafs(AnyType any, List<AnyType> result) {
    boolean hasChild = false;
    for (FeatureMap.Entry fme: any.getAny()) {
        Object child = fme.getValue();
        if (child instanceof AnyType) {
            hasChild = true;
            getLeafs((AnyType)child, result);
        }
    }
    if (!hasChild) {
        result.add(any);
    }
}
项目:clickwatch    文件:CompoundHandlerEventAdapter.java   
private void traverse(FeatureMap featureMap) {
    for(FeatureMap.Entry fme: featureMap) {
        boolean dive = false;
        if (!fme.getEStructuralFeature().getName().equals("text")) {
            dive = handleFME(fme);
        }
        Object fmeValue = fme.getValue();
        if (fmeValue instanceof AnyType && dive) {
            AnyType value = (AnyType)fmeValue;
            traverse(value.getAny());               
        }
    }
}
项目:clickwatch    文件:CompoundHandlerEventAdapter.java   
public boolean handleFME(FeatureMap.Entry fme) {
    String elementName = fme.getEStructuralFeature().getName();
    Object value = fme.getValue();
    Map<String, String> attributes = null;
    if (value instanceof AnyType) {
        attributes = getAttributeMap(((AnyType)fme.getValue()).getAnyAttribute());
    }
    if (elementName.equals("compoundhandler")) {
        long drift = pullTime - time(attributes.get("time"));
        if (driftMavrValues.size() == driftMavrSize) {
            driftMavrSum -= driftMavrValues.poll();             
        }
        driftMavrSum += drift;
        driftMavrValues.add(drift);
        inRecordMode = "1".equals(attributes.get("recordmode"));
    } else if (elementName.equals("compoundhandlerinfo")) {
        return false;
    } else if (elementName.equals("handler")) {
        currentHandlerName = attributes.get("name").replace(".", "/");
        if (inRecordMode) {
            if (attributes.get("overflow").equals("true")) {
                logger.log(ILogger.WARNING, "Overflow in compound handler detected"
                        + ", handler: " + currentHandlerName 
                        + ", node: " + connection, null);   
            }
        } else {
            createHandlerEvents(value, attributes);
        }
    } else if (elementName.equals("record")) {
        if (!attributes.get("update").equals("false")) {
            createHandlerEvents(value, attributes);
        }                       
    }
    return true;
}
项目:clickwatch    文件:XmlValueAdapter.java   
@Override
protected void setValue(Handler handler, String plainRealValue) {
    plainRealValue = EmfXmlUtil.stripProcessingInstructions(plainRealValue);
    XMLTypeDocumentRoot xml = null;
    try {
        xml = (XMLTypeDocumentRoot)EmfXmlUtil.deserializeXml("<xml>" + plainRealValue + "</xml>");
    } catch (Exception e) {
        logger.log(ILogger.WARNING, "could not parse handler value xml of handler " + handler.getQualifiedName() + ": " + plainRealValue, e);
        return;
    }
    FeatureMap xmlRootMixed = ((AnyType)xml.getMixed().getValue(0)).getMixed();
    if (xmlRootMixed.size() > 0) {
        for(FeatureMap.Entry entry: xmlRootMixed) {
            Object anyValue = entry.getValue();
            if (!(anyValue == null || (anyValue instanceof String && "".equals(((String)anyValue).trim())))) {
                EStructuralFeature anyFeature = entry.getEStructuralFeature();
                FeatureMap map = anyValue instanceof String ? handler.getMixed() : handler.getAny();
                if (map.isEmpty()) {
                    map.add(FeatureMapUtil.createRawEntry(anyFeature, anyValue));
                } else {
                    map.set(0, FeatureMapUtil.createRawEntry(anyFeature, anyValue));
                }
                EcoreUtil.delete(xml, true);
                return;
            }
        }                   
    }
}
项目:clickwatch    文件:XmlModelRepositoryTest.java   
@Test
public void testDeserialize() {     
    for (int i = 0; i < 2; i++) {
        EObject deserializedXml = EmfXmlUtil.deserializeXml("<foo>TEXT</foo>");

        assertNotNull(deserializedXml);
        assertTrue(deserializedXml instanceof XMLTypeDocumentRoot);
        assertEquals(1, ((XMLTypeDocumentRoot)deserializedXml).getMixed().size());
        assertTrue(((XMLTypeDocumentRoot)deserializedXml).getMixed().getValue(0) instanceof AnyType);
        assertEquals(1, ((AnyType)((XMLTypeDocumentRoot)deserializedXml).getMixed().getValue(0)).getMixed().size());
        assertEquals("TEXT", ((AnyType)((XMLTypeDocumentRoot)deserializedXml).getMixed().getValue(0)).getMixed().getValue(0));

        EcoreUtil.delete(deserializedXml, true);
    }
}
项目:clickwatch    文件:XmlModelRepositoryTest.java   
@Test
public void testBasicXDS() {
    Collection<EObject> xsd = new XSDEcoreBuilder().generate(URI.createFileURI(LINK_STAT_XSD));
    Collection<EPackage> xsdPackages = Collections2.transform(xsd, new Function<EObject, EPackage>() {
        @Override
        public EPackage apply(EObject input) {
            return (EPackage)input;
        }
    });
    final ResourceSet rs = new ResourceSetImpl();
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new XMLResourceFactoryImpl());
    for (EPackage ePackage: xsdPackages) {
        rs.getPackageRegistry().put(ePackage.getNsURI(), ePackage);
    }

    Resource xmlResource = rs.createResource(URI.createFileURI(LINK_STAT_XML));

    Map<String, Object> options = new HashMap<String, Object>();
    options.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    options.put(XMLResource.OPTION_ENCODING, "UTF-8");

    try {
        xmlResource.load(options);
    } catch (IOException e) {
        e.printStackTrace();
    }

    EObject model = xmlResource.getContents().get(0);
    Iterator<EObject> it = model.eAllContents();
    while (it.hasNext()) {
        assertTrue(! (it.next() instanceof AnyType));
    }   
}
项目:clickwatch    文件:XmlModelRepositoryTest.java   
@Test
public void testXSD() throws IOException {
    EPackage metaModel = xmlModelRepository.loadMetaModelFromXSD(URI.createFileURI(LINK_STAT_XSD), 
            TestUtil.readFileAsString(LINK_STAT_XSD));

    for (EClassifier eClassifier: metaModel.getEClassifiers()) {
        if (eClassifier instanceof EClass) {
            assertTrue(!eClassifier.getName().contains(" Type"));
        }
    }

    EObject result = EmfXmlUtil.deserializeModel(metaModel, TestUtil.readFileAsString(LINK_STAT_XML));

    assertNotNull(result);
    assertTrue(result.eClass().getEPackage().getName().equals(metaModel.getName()));

    EFactory factory = metaModel.getEFactoryInstance();
    EObject documentRoot = factory.create((EClass)metaModel.getEClassifier("DocumentRoot"));

    EStructuralFeature xMLNSPrefixMapFeature = documentRoot.eClass().getEStructuralFeature("xMLNSPrefixMap");
    documentRoot.eSet(xMLNSPrefixMapFeature, result.eGet(xMLNSPrefixMapFeature));

    EStructuralFeature xSISchemaLocation = documentRoot.eClass().getEStructuralFeature("xSISchemaLocation");
    documentRoot.eSet(xSISchemaLocation, result.eGet(xSISchemaLocation));

    String featureName = result.eContents().get(0).eContents().get(0).eContainmentFeature().getName();
    documentRoot.eSet(documentRoot.eClass().getEStructuralFeature(featureName), result.eContents().get(0).eContents().get(0));

    String serializedResult = EmfXmlUtil.serializeModel(metaModel, documentRoot);
    result = EmfXmlUtil.deserializeModel(metaModel, serializedResult);

    Iterator<EObject> it = result.eAllContents();
    while (it.hasNext()) {
        assertTrue(! (it.next() instanceof AnyType));
    }   
}
项目:clickwatch    文件:EmfXmlUtil.java   
public static AnyType createXMLText(String text) {
    AnyType result = XMLTypeFactory.eINSTANCE.createAnyType();
    result.getAny().add(XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text(), text);
    return result;
}
项目:clickwatch    文件:SpecificModelGenerator.java   
public EObject copyAny(AnyType source, EStructuralFeature feature) {
    return new AnyCopier(feature).copy(source);
}