congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ArchiveUtil
Code IndexAdd Tabnine to your IDE (free)

How to use
ArchiveUtil
in
org.eclipse.jst.j2ee.commonarchivecore.internal.util

Best Java code snippets using org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil (Showing top 20 results out of 315)

origin: org.eclipse/org.eclipse.jst.j2ee.core

protected Archive getResolvedArchive(String mfValue, EARFile ear) {
  String aUri = ArchiveUtil.deriveEARRelativeURI(mfValue, this);
  if (aUri == null)
    return null;
  try {
    return (Archive) ear.getFile(aUri);
  } catch (FileNotFoundException ex) {
    return null;
  } catch (ClassCastException ex2) {
    return null;
  }
}
origin: org.eclipse/org.eclipse.jst.j2ee.core

public static String[] getTokens(String aString) {
  return getTokens(aString, null);
}
origin: org.eclipse/org.eclipse.jst.j2ee.core

protected byte[] getClassBytesFor(String className) {
  if (className == null)
    return null;
  // Change the class name to a jar entry name
  String jarEntryName = ArchiveUtil.classNameToUri(className);
  return getData(getFile(jarEntryName));
}
origin: org.eclipse/org.eclipse.jst.j2ee.core

/**
 * Concatenates the two strings and ensures the correct separator is used in the path
 */
public static String getOSUri(String directoryname, String filename) {
  String osDirName = getOSUri(directoryname);
  String osFileName = getOSUri(filename);
  return concatUri(osDirName, osFileName, File.separatorChar);
}
origin: org.eclipse/org.eclipse.jst.j2ee.core

public static File createTempFile(String baseName) throws IOException {
  return createTempFile(baseName, getTempDirectory());
}
origin: org.eclipse/org.eclipse.jst.j2ee.core

public LoadStrategy createTempZipFileStrategyIfPossible(String uri, LoadStrategy parent) {
  if (!ArchiveUtil.shouldUseTempDirectoryForRead())
    return null;
  try {
    java.io.File tempFile = ArchiveUtil.createTempFile(uri);
    DeleteOnExitUtility.markForDeletion(tempFile);
    InputStream in = parent.getInputStream(uri);
    OutputStream out = new FileOutputStream(tempFile);
    ArchiveUtil.copy(in, out);
    return new TempZipFileLoadStrategyImpl(tempFile);
  } catch (IOException ex) {
    ArchiveUtil.inform(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.make_temp_file_WARN_, (new Object[]{uri})) + ex.getLocalizedMessage()); // = "Warning: Unable to create temp file for {0}.  This will impact performance."
  }
  return null;
}
origin: org.eclipse/org.eclipse.jst.j2ee.core

if (className == null)
  continue;
String classUri = org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil.classNameToUri(className);
String javaUri = org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil.classNameToJavaUri(className);
try {
  result.add(getFile(classUri));
origin: org.eclipse/org.eclipse.jst.j2ee.core

/**
 * Parse the manifest class path and the extra class path, and instantiate a URL classloader,
 * with a parent of the archiveClassLoader
 */
protected ClassLoader getClassPathClassLoader(ClassLoader parentCl) {
  List classPathComponents = new ArrayList();
  if (getManifest() != null)
    classPathComponents.addAll(Arrays.asList(getManifest().getClassPathTokenized()));
  String extraCp = getExtraClasspath();
  if (extraCp != null)
    classPathComponents.addAll(Arrays.asList(ArchiveUtil.getTokens(extraCp, ";")));//$NON-NLS-1$
  java.net.URL[] urlArray = ArchiveUtil.toLocalURLs(classPathComponents, getRootForRelativeDependentJars());
  return new java.net.URLClassLoader(urlArray, parentCl);
}
origin: org.eclipse/org.eclipse.jst.j2ee.core

/**
 * Read all the data from the input stream up until the first end of file character, add this
 * data to a byte array, and close the input stream; returns the byte array
 */
public static byte[] inputStreamToBytes(InputStream in) throws IOException {
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  copy(in, out);
  return out.toByteArray();
}
origin: org.eclipse/org.eclipse.jst.j2ee

String uri = ArchiveUtil.deriveEARRelativeURI(cp[i], anArchive);
if (uri == null) {
  invalidClassPathEntryWarning(cp[i], anArchive);
  Archive archive = (Archive) f;
  ModuleFile m = (ModuleFile) anArchive;
  if (!ArchiveUtil.isValidDependency(archive, m))
    invalidDepedencyWarning(cp[i], archive, m);
origin: org.eclipse/org.eclipse.jst.j2ee

  protected boolean isClassWithoutSource(File aFile) {
    String javaUri = ArchiveUtil.classUriToJavaUri(aFile.getURI());
    if (javaUri == null)
      return false;
    return !archive.containsFile(javaUri);
  }
}
origin: org.eclipse/org.eclipse.jst.j2ee.core

protected void addFiles(java.io.File aDirectory, List aList) {
  String[] fileNames = aDirectory.list();
  if (fileNames == null)
    return;
  for (int i = 0; i < fileNames.length; i++) {
    String fileName = ArchiveUtil.concatUri(aDirectory.getPath(), fileNames[i], SEPARATOR_CHAR);
    if (fileNames[i] == null || (IS_AIX && ".backup".equals(fileNames[i]))) //$NON-NLS-1$
      continue;
    java.io.File aFile = new java.io.File(fileName);
    if (!aFile.exists())
      continue;
    //This could occur on some windows machines, eg C:\pagefile.sys
    //throw new RuntimeException("Error scanning directory structure");
    if (aFile.isDirectory() && !isArchive(getURIFrom(aFile))) {
      addDirectory(aFile, aList);
    } else {
      addFile(aFile, aList);
    }
  }
}
origin: org.eclipse/org.eclipse.jst.j2ee.core

public static File createTempDirectory(String baseName, File parentDirectory) throws IOException {
  File tempFile = createTempFile(baseName, parentDirectory);
  tempFile.delete();
  tempFile.mkdir();
  return tempFile;
}
origin: org.eclipse/org.eclipse.jst.j2ee.core

/**
 * @see com.ibm.etools.commonarchive.Archive
 */
public void extractNoReopen(int expansionFlags) throws SaveFailureException {
  String aUri = getURI();
  java.io.File aDir = new java.io.File(aUri);
  boolean inUse = getLoadStrategy().isUsing(aDir);
  try {
    java.io.File destinationDir = inUse ? ArchiveUtil.createTempDirectory(aUri, aDir.getCanonicalFile().getParentFile()) : aDir;
    SaveStrategy aSaveStrategy = createSaveStrategyForDirectory(destinationDir, expansionFlags);
    save(aSaveStrategy);
    aSaveStrategy.close();
    close();
    if (inUse) {
      cleanupAfterTempSave(aUri, aDir, destinationDir);
    }
  } catch (java.io.IOException ex) {
    throw new SaveFailureException(CommonArchiveResourceHandler.getString(CommonArchiveResourceHandler.error_saving_EXC_, (new Object[]{uri})), ex); // = "Error saving "
  }
}
origin: org.eclipse/org.eclipse.jst.j2ee.ejb

/**
 * @see org.eclipse.wst.validation.internal.operations.IWorkbenchContext#getPortableName(IResource)
 */
public String getPortableName(IResource resource) {
  // Return the URI of the object.
  if (!(resource instanceof IFile)) {
    return super.getPortableName(resource);
  }
  IFile file = (IFile) resource;
  if ((resource.getFileExtension() != null) && (resource.getFileExtension().equals("java"))) { //$NON-NLS-1$
    JavaClass clazz = JemProjectUtilities.getJavaClass(file);
    if (clazz == null) {
      return super.getPortableName(resource);
    }
    return ArchiveUtil.classNameToJavaUri(clazz.getQualifiedName());
  } else if ((resource.getFileExtension() != null) && (resource.getFileExtension().equals("class"))) { //$NON-NLS-1$
    JavaClass clazz = JemProjectUtilities.getJavaClass(file);
    if (clazz == null) {
      return super.getPortableName(resource);
    }
    return ArchiveUtil.classNameToUri(clazz.getQualifiedName());
  } else if (resource.getName().equals("ejb-jar.xml")) //$NON-NLS-1$
    return J2EEConstants.EJBJAR_DD_URI;
  return null;
}
origin: org.eclipse/org.eclipse.jst.j2ee

protected IFile saveFile(File aFile, IProject p) throws IOException {
  IFile iFile = p.getFile(aFile.getURI());
  WorkbenchByteArrayOutputStream out = new WorkbenchByteArrayOutputStream(iFile);
  ArchiveUtil.copy(aFile.getInputStream(), out);
  return iFile;
}
origin: org.eclipse/org.eclipse.jst.j2ee.core

String convertedClassURI = classURI;
if (classURI.endsWith(".class")) //$NON-NLS-1$
  convertedClassURI = ArchiveUtil.classUriToJavaUri(aClassFile.getURI());
else 
  return null;
origin: org.eclipse/org.eclipse.jst.j2ee.core

protected File addCopyFileAddingPrefix(File aFile, String uriPrefix) throws DuplicateObjectException {
  String swizzledUri = aFile.getURI();
  if (!swizzledUri.startsWith(uriPrefix)) {
    swizzledUri = ArchiveUtil.concatUri(uriPrefix, swizzledUri, '/');
  }
  checkAddValid(swizzledUri);
  File copy = copy(aFile);
  copy.setURI(swizzledUri);
  getFiles().add(copy);
  return copy;
}
origin: org.eclipse/org.eclipse.jst.j2ee.core

try {
  try {
    java.io.File destinationFile = fileExisted ? ArchiveUtil.createTempFile(aUri, aFile.getCanonicalFile().getParentFile()) : aFile;
    aSaveStrategy = createSaveStrategyForJar(destinationFile);
    save(aSaveStrategy);
origin: org.eclipse/org.eclipse.jst.j2ee.core

/**
 * Leverage the java.io.File apis to resolve things like "./xxx" and "../xxx" into uris of
 * entries in the ear file
 * 
 * @param classpathEntry -
 *            a classpath entry from the manifest of
 * @anArchive
 * @param anArchive -
 *            the archive to which the dependent jar is relative
 * 
 * @return a cananonicalized relative uri of an entry in an ear file representing the dependent
 *         jar
 */
public static String deriveEARRelativeURI(String classpathEntry, Archive anArchive) {
  return deriveEARRelativeURI(classpathEntry, anArchive.getURI());
}
org.eclipse.jst.j2ee.commonarchivecore.internal.utilArchiveUtil

Javadoc

This is a utility class to hold helper methods common to multiple classes in the archive support packages

Most used methods

  • deriveEARRelativeURI
    Leverage the java.io.File apis to resolve things like "./xxx" and "../xxx" into uris of entries in t
  • getTokens
  • classNameToJavaUri
  • classNameToUri
  • classUriToJavaUri
    For a given uri of a .class file, derive the uri of the .java file; takes into consideration inner c
  • copy
    Copy all the data from the input stream to the output stream up until the first end of file characte
  • concatUri
    Concatenates the two strings with a separator, if necessary
  • createTempDirectory
  • createTempFile
  • delete
    deletes a file from the file system; for directories, recurse the subdirectories and delete them as
  • getArchive
    For the given resource, return the owning module file; for example, retrieve the EJBJarFile that own
  • getFastSpecVersion
  • getArchive,
  • getFastSpecVersion,
  • getFileNameExtension,
  • getFileNameParent,
  • getFileNameTail,
  • getJ2EE13PublicAndSystemIdFor,
  • getModuleFile,
  • getModuleFileTypeName,
  • getModuleFileUsingAltDD,
  • getOSUri

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getContentResolver (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • notifyDataSetChanged (ArrayAdapter)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now