Esempio n. 1
0
 public byte[] getBytes() throws JavaModelException {
   JavaElement pkg = (JavaElement) getParent();
   if (pkg instanceof JarPackageFragment) {
     JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent();
     ZipFile zip = null;
     try {
       zip = root.getJar();
       String entryName = Util.concatWith(((PackageFragment) pkg).names, getElementName(), '/');
       ZipEntry ze = zip.getEntry(entryName);
       if (ze != null) {
         return org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
       }
       throw new JavaModelException(
           new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this));
     } catch (IOException ioe) {
       throw new JavaModelException(ioe, IJavaModelStatusConstants.IO_EXCEPTION);
     } catch (CoreException e) {
       if (e instanceof JavaModelException) {
         throw (JavaModelException) e;
       } else {
         throw new JavaModelException(e);
       }
     } finally {
       JavaModelManager.getJavaModelManager().closeZipFile(zip);
     }
   } else {
     IFile file = (IFile) resource();
     return Util.getResourceContentsAsByteArray(file);
   }
 }
Esempio n. 2
0
 /*
  * @see JavaElement
  */
 public IJavaElement getHandleFromMemento(
     String token, MementoTokenizer memento, WorkingCopyOwner owner) {
   switch (token.charAt(0)) {
     case JEM_TYPE:
       if (!memento.hasMoreTokens()) return this;
       String typeName = memento.nextToken();
       JavaElement type = new BinaryType(this, typeName);
       return type.getHandleFromMemento(memento, owner);
   }
   return null;
 }