public static void setParent(DatabindContext ctxt, EObject parent) { ctxt.setAttribute(Internals.CURRENT_PARENT, parent); }
public static void setDataType(DatabindContext ctxt, EClassifier type) { ctxt.setAttribute(Internals.CURRENT_DATATYPE, type); }
public static void setDataType(DatabindContext ctxt, EClassifier type) { ctxt.setAttribute(Internals.CURRENT_DATATYPE, type); }
public static void setFeature(DatabindContext ctxt, EStructuralFeature feature) { ctxt.setAttribute(Internals.CURRENT_FEATURE, feature); }
public static void setFeature(DatabindContext ctxt, EStructuralFeature feature) { ctxt.setAttribute(Internals.CURRENT_FEATURE, feature); }
public static void setParent(DatabindContext ctxt, EObject parent) { ctxt.setAttribute(Internals.CURRENT_PARENT, parent); }
public static void init(Resource resource, DatabindContext context) { if (context.getAttribute(Internals.INIT) != null) { return; } ReferenceEntries entries = new ReferenceEntries(); EcoreTypeFactory ecoreType = new EcoreTypeFactory(); ResourceSet resourceSet = resource.getResourceSet(); context.setAttribute(Attributes.RESOURCE, resource); context.setAttribute(Attributes.RESOURCE_SET, resourceSet); context.setAttribute(Internals.REFERENCE_ENTRIES, entries); context.setAttribute(Internals.TYPE_FACTORY, ecoreType); context.setAttribute(Internals.INIT, true); }
public static void init(Resource resource, DatabindContext context) { if (context.getAttribute(Internals.INIT) != null) { return; } ReferenceEntries entries = new ReferenceEntries(); EcoreTypeFactory ecoreType = new EcoreTypeFactory(); ResourceSet resourceSet = resource.getResourceSet(); context.setAttribute(Attributes.RESOURCE, resource); context.setAttribute(Attributes.RESOURCE_SET, resourceSet); context.setAttribute(Internals.REFERENCE_ENTRIES, entries); context.setAttribute(Internals.TYPE_FACTORY, ecoreType); context.setAttribute(Internals.INIT, true); }
private static Set<EClass> initAllTypes(DatabindContext ctxt) { EPackage.Registry global = EPackage.Registry.INSTANCE; ResourceSet resourceSet = getResourceSet(ctxt); EPackage.Registry local = resourceSet.getPackageRegistry(); Map<String, Object> registry = new HashMap<>(); registry.putAll(global); registry.putAll(local); Set<EClass> types = registry.values().stream() .flatMap(e -> stream(spliteratorUnknownSize(((EPackage) e).eAllContents(), ORDERED), false)) .filter(e -> e instanceof EClass) .map(e -> (EClass) e) .collect(Collectors.toSet()); ctxt.setAttribute(Internals.ALL_TYPES, types); return types; }
private static Set<EClass> initAllTypes(DatabindContext ctxt) { EPackage.Registry global = EPackage.Registry.INSTANCE; ResourceSet resourceSet = getResourceSet(ctxt); EPackage.Registry local = resourceSet.getPackageRegistry(); Map<String, Object> registry = new HashMap<>(); registry.putAll(global); registry.putAll(local); Set<EClass> types = registry.values().stream() .flatMap(e -> stream(spliteratorUnknownSize(((EPackage) e).eAllContents(), ORDERED), false)) .filter(e -> e instanceof EClass) .map(e -> (EClass) e) .collect(Collectors.toSet()); ctxt.setAttribute(Internals.ALL_TYPES, types); return types; }
public static URI getURI(DatabindContext ctxt, EObject object) { if (object == null) { return null; } @SuppressWarnings("unchecked") Map<EObject, URI> objects = (Map<EObject, URI>) ctxt.getAttribute(Internals.MAP_OF_OBJECTS); if (objects == null) { ctxt.setAttribute(Internals.MAP_OF_OBJECTS, objects = new HashMap<>()); } URI uri = objects.get(object); if (uri == null) { objects.put(object, uri = EcoreUtil.getURI(object)); } return uri; }
public static URI getURI(DatabindContext ctxt, EObject object) { if (object == null) { return null; } @SuppressWarnings("unchecked") Map<EObject, URI> objects = (Map<EObject, URI>) ctxt.getAttribute(Internals.MAP_OF_OBJECTS); if (objects == null) { ctxt.setAttribute(Internals.MAP_OF_OBJECTS, objects = new HashMap<>()); } URI uri = objects.get(object); if (uri == null) { objects.put(object, uri = EcoreUtil.getURI(object)); } return uri; }
public static ResourceSet getResourceSet(DatabindContext context) { ResourceSet resourceSet; try { resourceSet = (ResourceSet) context.getAttribute(Attributes.RESOURCE_SET); } catch (ClassCastException e) { resourceSet = null; } if (resourceSet == null) { context.setAttribute(Attributes.RESOURCE_SET, resourceSet = new ResourceSetImpl()); } return resourceSet; }
public static ReferenceEntries getEntries(DatabindContext ctxt) { try { return (ReferenceEntries) ctxt.getAttribute(Internals.REFERENCE_ENTRIES); } catch (ClassCastException e) { ReferenceEntries entries = new ReferenceEntries(); ctxt.setAttribute(Internals.REFERENCE_ENTRIES, entries); return entries; } }
public static ReferenceEntries getEntries(DatabindContext ctxt) { try { return (ReferenceEntries) ctxt.getAttribute(Internals.REFERENCE_ENTRIES); } catch (ClassCastException e) { ReferenceEntries entries = new ReferenceEntries(); ctxt.setAttribute(Internals.REFERENCE_ENTRIES, entries); return entries; } }
@Deprecated public static void prepare(DatabindContext ctxt) { if (ctxt.getAttribute(Internals.INIT) != null) { return; } if (getResourceSet(ctxt) == null) { ctxt.setAttribute(Attributes.RESOURCE_SET, new ResourceSetImpl()); } if (getEntries(ctxt) == null) { ctxt.setAttribute(Internals.REFERENCE_ENTRIES, new ReferenceEntries()); } }
public static EcoreTypeFactory getTypeFactory(DatabindContext ctxt) { EcoreTypeFactory factory = (EcoreTypeFactory) ctxt.getAttribute(Internals.TYPE_FACTORY); if (factory == null) { ctxt.setAttribute(Internals.TYPE_FACTORY, factory = new EcoreTypeFactory()); } return factory; }
public static EcoreTypeFactory getTypeFactory(DatabindContext ctxt) { EcoreTypeFactory factory = (EcoreTypeFactory) ctxt.getAttribute(Internals.TYPE_FACTORY); if (factory == null) { ctxt.setAttribute(Internals.TYPE_FACTORY, factory = new EcoreTypeFactory()); } return factory; }
public static ResourceSet getResourceSet(DatabindContext context) { ResourceSet resourceSet; try { resourceSet = (ResourceSet) context.getAttribute(Attributes.RESOURCE_SET); } catch (ClassCastException e) { resourceSet = null; } if (resourceSet == null) { context.setAttribute(Attributes.RESOURCE_SET, resourceSet = new ResourceSetImpl()); } return resourceSet; }
@Deprecated public static void prepare(DatabindContext ctxt) { if (ctxt.getAttribute(Internals.INIT) != null) { return; } if (getResourceSet(ctxt) == null) { ctxt.setAttribute(Attributes.RESOURCE_SET, new ResourceSetImpl()); } if (getEntries(ctxt) == null) { ctxt.setAttribute(Internals.REFERENCE_ENTRIES, new ReferenceEntries()); } }