private static String primGetNonPlatformURIString(URI platformURI) { String uriString = platformURI.toString(); //"platform:/resource/" is 19 characters. return uriString.substring(19, uriString.length()); }
protected URI normalizeEmptyProtocol(URI aFileUri, String fragment) { //Make the relative path absolute and return a platform URI. IPath path = new Path(aFileUri.toString()); return normalizeToWorkspaceURI(path, fragment); }
/** * When running under Eclipse, queries the workspace to determine the correct encoding for the file identified by * the given workspace path URI. When running stand-alone, returns null. */ protected String getEncoding(URI workspacePath) { if (EMFPlugin.IS_ECLIPSE_RUNNING) { return EclipseHelper.getEncoding(workspacePath.toString()); } return null; }
@Override public Node representData(Object data) { if (!(data instanceof URI)) throw new IllegalArgumentException("URIRepresenter -- data should be a URI"); URI uri = (URI) data; String value = uri.toString(); return representScalar(new Tag("!emf.URI"), value); }
protected URI normalizeWorkspaceProtocol(URI aWorkspaceURI, String fragment) { URI result; String uriString = aWorkspaceURI.toString(); uriString = uriString.substring(JEMUtilPlugin.WORKSPACE_PROTOCOL.length() + 1); result = URI.createPlatformResourceURI(uriString); if (fragment != null) result = appendFragment(aWorkspaceURI, fragment); return result; }
public String getPackageName(URI javaURI) { if (isTypeURI(javaURI) || isPackageURI(javaURI)) { if (javaURI.segmentCount() == 1) { return javaURI.segment(0); } else if (javaURI.segmentCount() == 0) return ""; //$NON-NLS-1$ else throw new IllegalArgumentException(javaURI.toString()); } else throw new IllegalArgumentException(javaURI.toString()); }
/** * Returns the first element in the extent of the resource * * @throws EmptyResourceException - * thrown if the extent is empty */ public static EObject getRoot(Resource aResource) throws EmptyResourceException { EList extent = aResource.getContents(); if (extent.size() < 1) { throw new EmptyResourceException(aResource.getURI().toString()); } return (EObject) extent.get(0); }
/** * Return a String represenation of the platformURI without the leading "platform:/resource/" if present. * * @param platformURI * @return * @since 1.0.0 */ public static String getNonPlatformURIString(URI platformURI) { if (isPlatformResourceURI(platformURI)) { return primGetNonPlatformURIString(platformURI); } return platformURI.toString(); }
/** * createFieldRef - return a JavaURL reference to the named field in the named Java class in the form "package.class_field" * @deprecated no replacement at this time. */ public static Field createFieldRef(String className, String fieldName) { Field ref = JavaRefFactory.eINSTANCE.createField(); URI classURI = JavaRefFactory.eINSTANCE.createTypeURI(className); ((InternalEObject) ref).eSetProxyURI(URI.createURI(classURI.toString()+ReflectionAdaptor.C_CLASS_MEMBER_DELIMITER+fieldName)); return ref; }
private static String getFileName(XSDSchema schema) { URI schemaURI = schema.eResource().getURI(); IPath filePath = new Path(schemaURI.toString()); return filePath.removeFileExtension().lastSegment().toString(); } }
public String getTypeName(URI typeURI) { if (isTypeURI(typeURI)) { return primGetTypeName(typeURI.fragment()); } else throw new IllegalArgumentException(typeURI.toString()); }
/** * Safety check method to ensure that the version of the dd object can be computed. */ public static void checkDDObjectForVersion(EObject dd) { if (dd.eIsProxy()) { String proxyUri = ((InternalEObject)dd).eProxyURI().toString(); String message = MOFJ2EEResourceHandler.getString(MOFJ2EEResourceHandler.J2EE_VERSION_PROXY_ERROR, new Object[]{proxyUri}); throw new IllegalStateException(message); } else if (dd.eResource() == null) { String message = MOFJ2EEResourceHandler.J2EE_VERSION_NULL_ERROR; throw new IllegalStateException(message); } }
public String getFullTypeName(URI typeURI) { String pkgName = getPackageName(typeURI); if (!isTypeURI(typeURI)) throw new IllegalArgumentException(typeURI.toString()); if (pkgName.length() > 0) return pkgName+'.'+getTypeName(typeURI); else return typeURI.fragment(); }
public InputStream createInputStream(URI uri) throws IOException { InputStream in = null; if (resourcesPath != null) in = makeInputStream(uri); if (in != null) return in; return getArchive().getInputStream(uri.toString()); }
@Override protected String getURITextInitialValue() { URI uri = getModelExporter().getDirectoryURI(); return uri == null ? super.getURITextInitialValue() : uri.toString(); }
/** * Creates an <code>InputStream</code> for the file identified by the given workspace path URI. */ protected InputStream createInputStream(URI workspacePath) throws Exception { if (EMFPlugin.IS_ECLIPSE_RUNNING) { return EclipseHelper.createInputStream(workspacePath.toString()); } return getURIConverter().createInputStream(toPlatformResourceURI(workspacePath)); }
protected static ModuleFile getModuleFileUsingAltDD(EARFile ear, Resource res) { if (res == null) return null; String uri = res.getURI().toString(); Module m = ear.getDeploymentDescriptor().getModuleHavingAltDD(uri); if (m == null) return null; ModuleRef ref = ear.getModuleRef(m); if (ref == null) return null; return ref.getModuleFile(); }
public Resource createResource(URI uri) { JavaXMIResource resource = new JavaXMIResource(uri); resource.setReflectionKey(new JavaReflectionKey(extensions, resource)); String uriString = uri.toString(); createJavaPackage(stripScheme(uriString), uriString, resource); return resource; }
protected static ModuleFile getModuleFileUsingAltDD(EARFile ear, Resource res) { if (res == null) return null; String uri = res.getURI().toString(); Module m = ear.getDeploymentDescriptor().getModuleHavingAltDD(uri); if (m == null) return null; ModuleRef ref = ear.getModuleRef(m); if (ref == null) return null; return ref.getModuleFile(); }
protected boolean shouldSave(Resource res) { if (!res.isModified() && getArchive().getOptions().saveOnlyDirtyMofResources()) return false; return shouldSave(res.getURI().toString()); }