Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 59091 Details for
Bug 150244
[API] Add getBytes() on IClassFile
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
patch_150244.txt (text/plain), 2.85 KB, created by
Olivier Thomann
on 2007-02-15 14:52:15 EST
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2007-02-15 14:52:15 EST
Size:
2.85 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/core/IClassFile.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClassFile.java,v >retrieving revision 1.22 >diff -u -r1.22 IClassFile.java >--- model/org/eclipse/jdt/core/IClassFile.java 24 Nov 2006 13:56:36 -0000 1.22 >+++ model/org/eclipse/jdt/core/IClassFile.java 15 Feb 2007 19:49:58 -0000 >@@ -78,7 +78,15 @@ > * @since 3.2 > */ > ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException; >- >+/** >+ * Returns the bytes contained in this class file. >+ * >+ * @return the bytes contained in this class file >+ * >+ * @exception JavaModelException if this element does not exist or if an >+ * exception occurs while accessing its corresponding resource >+ */ >+byte[] getBytes() throws JavaModelException; > /** > * Returns the type contained in this class file. > * >Index: model/org/eclipse/jdt/internal/core/ClassFile.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java,v >retrieving revision 1.129 >diff -u -r1.129 ClassFile.java >--- model/org/eclipse/jdt/internal/core/ClassFile.java 24 Nov 2006 13:56:36 -0000 1.129 >+++ model/org/eclipse/jdt/internal/core/ClassFile.java 15 Feb 2007 19:49:59 -0000 >@@ -298,6 +298,36 @@ > } > } > } >+ >+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) getResource(); >+ return Util.getResourceContentsAsByteArray(file); >+ } >+} > private IBinaryType getJarBinaryTypeInfo(PackageFragment pkg) throws CoreException, IOException, ClassFormatException { > JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent(); > ZipFile zip = null;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 150244
: 59091 |
59092
|
59117