Java Doc for IWorkingCopy.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » core » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jdt » org.eclipse.jdt.core 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.eclipse.jdt.core.IWorkingCopy

IWorkingCopy
public interface IWorkingCopy (Code)
Common protocol for Java elements that support working copies.

A working copy of a Java element acts just like a regular element (handle), except it is not attached to an underlying resource. A working copy is not visible to the rest of the Java model. Changes in a working copy's buffer are not realized in a resource. To bring the Java model up-to-date with a working copy's contents, an explicit commit must be performed on the working copy. Other operations performed on a working copy update the contents of the working copy's buffer but do not commit the contents of the working copy.

Note: The contents of a working copy is determined when a working copy is created, based on the current content of the element the working copy is created from. If a working copy is an IOpenable and is explicitly closed, the working copy's buffer will be thrown away. However, clients should not explicitly open and close working copies.

The client that creates a working copy is responsible for destroying the working copy. The Java model will never automatically destroy or close a working copy. (Note that destroying a working copy does not commit it to the model, it only frees up the memory occupied by the element). After a working copy is destroyed, the working copy cannot be accessed again. Non-handle methods will throw a JavaModelException indicating the Java element does not exist.

A working copy cannot be created from another working copy. Calling getWorkingCopy on a working copy returns the receiver.

This interface is not intended to be implemented by clients.

ICompilationUnit




Method Summary
 voidcommit(boolean force, IProgressMonitor monitor)
     Commits the contents of this working copy to its original element and underlying resource, bringing the Java model up-to-date with the current contents of the working copy.

It is possible that the contents of the original resource have changed since this working copy was created, in which case there is an update conflict. The value of the force parameter effects the resolution of such a conflict:

  • true - in this case the contents of this working copy are applied to the underlying resource even though this working copy was created before a subsequent change in the resource
  • false - in this case a JavaModelException is thrown

Since 2.1, a working copy can be created on a not-yet existing compilation unit.

 voiddestroy()
     Destroys this working copy, closing its buffer and discarding its structure.
 IJavaElement[]findElements(IJavaElement element)
     Finds the elements in this compilation unit that correspond to the given element.
 ITypefindPrimaryType()
     Finds the primary type of this compilation unit (that is, the type with the same name as the compilation unit), or null if no such a type exists.
 IJavaElementfindSharedWorkingCopy(IBufferFactory bufferFactory)
     Finds the shared working copy for this element, given a IBuffer factory.
 IJavaElementgetOriginal(IJavaElement workingCopyElement)
     Returns the original element the specified working copy element was created from, or null if this is not a working copy element.
 IJavaElementgetOriginalElement()
     Returns the original element this working copy was created from, or null if this is not a working copy.
 IJavaElementgetSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor problemRequestor)
     Returns a shared working copy on this element using the given factory to create the buffer, or this element if this element is already a working copy. This API can only answer an already existing working copy if it is based on the same original compilation unit AND was using the same buffer factory (that is, as defined by Object.equals).

The life time of a shared working copy is as follows:

  • The first call to getSharedWorkingCopy(...) creates a new working copy for this element
  • Subsequent calls increment an internal counter.
  • A call to destroy() decrements the internal counter.
  • When this counter is 0, the working copy is destroyed.
So users of this method must destroy exactly once the working copy.

Note that the buffer factory will be used for the life time of this working copy, that is if the working copy is closed then reopened, this factory will be used. The buffer will be automatically initialized with the original's compilation unit content upon creation.

When the shared working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.
Parameters:
  monitor - a progress monitor used to report progress while opening this compilation unitor null if no progress should be reported
Parameters:
  factory - the factory that creates a buffer that is used to get the content of the working copyor null if the internal factory should be used
Parameters:
  problemRequestor - a requestor which will get notified of problems detected duringreconciling as they are discovered.

 IJavaElementgetWorkingCopy()
     Returns a new working copy of this element if this element is not a working copy, or this element if this element is already a working copy.

Note: if intending to share a working copy amongst several clients, then #getSharedWorkingCopy should be used instead.

When the working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.

Since 2.1, a working copy can be created on a not-yet existing compilation unit.

 IJavaElementgetWorkingCopy(IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor problemRequestor)
     Returns a new working copy of this element using the given factory to create the buffer, or this element if this element is already a working copy. Note that this factory will be used for the life time of this working copy, that is if the working copy is closed then reopened, this factory will be reused. The buffer will be automatically initialized with the original's compilation unit content upon creation.

Note: if intending to share a working copy amongst several clients, then #getSharedWorkingCopy should be used instead.

When the working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.

Since 2.1, a working copy can be created on a not-yet existing compilation unit.

 booleanisBasedOn(IResource resource)
     Returns whether this working copy's original element's content has not changed since the inception of this working copy.
 booleanisWorkingCopy()
     Returns whether this element is a working copy.
 IMarker[]reconcile()
     Reconciles the contents of this working copy. It performs the reconciliation by locally caching the contents of the working copy, updating the contents, then creating a delta over the cached contents and the new contents, and finally firing this delta.

If the working copy hasn't changed, then no problem will be detected, this is equivalent to IWorkingCopy#reconcile(false, null).

Compilation problems found in the new contents are notified through the IProblemRequestor interface which was passed at creation, and no longer as transient markers.

 voidreconcile(boolean forceProblemDetection, IProgressMonitor monitor)
     Reconciles the contents of this working copy. It performs the reconciliation by locally caching the contents of the working copy, updating the contents, then creating a delta over the cached contents and the new contents, and finally firing this delta.

The boolean argument allows to force problem detection even if the working copy is already consistent.

Compilation problems found in the new contents are notified through the IProblemRequestor interface which was passed at creation, and no longer as transient markers.

 voidrestore()
     Restores the contents of this working copy to the current contents of this working copy's original element.



Method Detail
commit
void commit(boolean force, IProgressMonitor monitor) throws JavaModelException(Code)
Commits the contents of this working copy to its original element and underlying resource, bringing the Java model up-to-date with the current contents of the working copy.

It is possible that the contents of the original resource have changed since this working copy was created, in which case there is an update conflict. The value of the force parameter effects the resolution of such a conflict:

  • true - in this case the contents of this working copy are applied to the underlying resource even though this working copy was created before a subsequent change in the resource
  • false - in this case a JavaModelException is thrown

Since 2.1, a working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.


Parameters:
  force - a flag to handle the cases when the contents of the original resource have changedsince this working copy was created
Parameters:
  monitor - the given progress monitor
exception:
  JavaModelException - if this working copy could not commit. Reasons include:
  • A CoreException occurred while updating an underlying resource
  • This element is not a working copy (INVALID_ELEMENT_TYPES)
  • A update conflict (described above) (UPDATE_CONFLICT)
ICompilationUnit.commitWorkingCopy(booleanIProgressMonitor)



destroy
void destroy()(Code)
Destroys this working copy, closing its buffer and discarding its structure. Subsequent attempts to access non-handle information for this working copy will result in IJavaModelExceptions. Has no effect if this element is not a working copy.

If this working copy is shared, it is destroyed only when the number of calls to destroy() is the same as the number of calls to getSharedWorkingCopy(IProgressMonitor, IBufferFactory).

When it is destroyed, a REMOVED IJavaElementDelta is reported on this working copy.

ICompilationUnit.discardWorkingCopy



findElements
IJavaElement[] findElements(IJavaElement element)(Code)
Finds the elements in this compilation unit that correspond to the given element. An element A corresponds to an element B if:
  • A has the same element name as B.
  • If A is a method, A must have the same number of arguments as B and the simple names of the argument types must be equals.
  • The parent of A corresponds to the parent of B recursively up to their respective compilation units.
  • A exists.
Returns null if no such java elements can be found or if the given element is not included in a compilation unit.
Parameters:
  element - the given element the found elements in this compilation unit that correspond to the given element
since:
   2.0 ICompilationUnit.findElements(IJavaElement)



findPrimaryType
IType findPrimaryType()(Code)
Finds the primary type of this compilation unit (that is, the type with the same name as the compilation unit), or null if no such a type exists. the found primary type of this compilation unit, or null if no such a type exists
since:
   2.0ITypeRoot.findPrimaryType



findSharedWorkingCopy
IJavaElement findSharedWorkingCopy(IBufferFactory bufferFactory)(Code)
Finds the shared working copy for this element, given a IBuffer factory. If no working copy has been created for this element associated with this buffer factory, returns null.

Users of this method must not destroy the resulting working copy.
Parameters:
  bufferFactory - the given IBuffer factory the found shared working copy for this element, null if none
See Also:   IBufferFactory
since:
   2.0ICompilationUnit.findWorkingCopy(WorkingCopyOwner)




getOriginal
IJavaElement getOriginal(IJavaElement workingCopyElement)(Code)
Returns the original element the specified working copy element was created from, or null if this is not a working copy element. This is a handle only method, the returned element may or may not exist.
Parameters:
  workingCopyElement - the specified working copy element the original element the specified working copy element was created from,or null if this is not a working copy elementIJavaElement.getPrimaryElement



getOriginalElement
IJavaElement getOriginalElement()(Code)
Returns the original element this working copy was created from, or null if this is not a working copy. the original element this working copy was created from,or null if this is not a working copyICompilationUnit.findPrimaryType



getSharedWorkingCopy
IJavaElement getSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException(Code)
Returns a shared working copy on this element using the given factory to create the buffer, or this element if this element is already a working copy. This API can only answer an already existing working copy if it is based on the same original compilation unit AND was using the same buffer factory (that is, as defined by Object.equals).

The life time of a shared working copy is as follows:

  • The first call to getSharedWorkingCopy(...) creates a new working copy for this element
  • Subsequent calls increment an internal counter.
  • A call to destroy() decrements the internal counter.
  • When this counter is 0, the working copy is destroyed.
So users of this method must destroy exactly once the working copy.

Note that the buffer factory will be used for the life time of this working copy, that is if the working copy is closed then reopened, this factory will be used. The buffer will be automatically initialized with the original's compilation unit content upon creation.

When the shared working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.
Parameters:
  monitor - a progress monitor used to report progress while opening this compilation unitor null if no progress should be reported
Parameters:
  factory - the factory that creates a buffer that is used to get the content of the working copyor null if the internal factory should be used
Parameters:
  problemRequestor - a requestor which will get notified of problems detected duringreconciling as they are discovered. The requestor can be set to null indicatingthat the client is not interested in problems.
exception:
  JavaModelException - if the contents of this element cannot be determined. a shared working copy on this element using the given factory to createthe buffer, or this element if this element is already a working copy
See Also:   IBufferFactory
See Also:   IProblemRequestor
since:
   2.0ICompilationUnit.getWorkingCopy(WorkingCopyOwnerIProblemRequestorIProgressMonitor)




getWorkingCopy
IJavaElement getWorkingCopy() throws JavaModelException(Code)
Returns a new working copy of this element if this element is not a working copy, or this element if this element is already a working copy.

Note: if intending to share a working copy amongst several clients, then #getSharedWorkingCopy should be used instead.

When the working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.

Since 2.1, a working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.


exception:
  JavaModelException - if the contents of this element cannot be determined. a new working copy of this element if this element is nota working copy, or this element if this element is already a working copyICompilationUnit.getWorkingCopy(IProgressMonitor)



getWorkingCopy
IJavaElement getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException(Code)
Returns a new working copy of this element using the given factory to create the buffer, or this element if this element is already a working copy. Note that this factory will be used for the life time of this working copy, that is if the working copy is closed then reopened, this factory will be reused. The buffer will be automatically initialized with the original's compilation unit content upon creation.

Note: if intending to share a working copy amongst several clients, then #getSharedWorkingCopy should be used instead.

When the working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.

Since 2.1, a working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.


Parameters:
  monitor - a progress monitor used to report progress while opening this compilation unitor null if no progress should be reported
Parameters:
  factory - the factory that creates a buffer that is used to get the content of the working copyor null if the internal factory should be used
Parameters:
  problemRequestor - a requestor which will get notified of problems detected duringreconciling as they are discovered. The requestor can be set to null indicatingthat the client is not interested in problems.
exception:
  JavaModelException - if the contents of this element cannot be determined. a new working copy of this element using the given factory to createthe buffer, or this element if this element is already a working copy
since:
   2.0ICompilationUnit.getWorkingCopy(WorkingCopyOwnerIProblemRequestorIProgressMonitor)



isBasedOn
boolean isBasedOn(IResource resource)(Code)
Returns whether this working copy's original element's content has not changed since the inception of this working copy.
Parameters:
  resource - this working copy's resource true if this working copy's original element's contenthas not changed since the inception of this working copy, false otherwiseICompilationUnit.hasResourceChanged



isWorkingCopy
boolean isWorkingCopy()(Code)
Returns whether this element is a working copy. true if this element is a working copy, false otherwiseICompilationUnit.isWorkingCopy



reconcile
IMarker[] reconcile() throws JavaModelException(Code)
Reconciles the contents of this working copy. It performs the reconciliation by locally caching the contents of the working copy, updating the contents, then creating a delta over the cached contents and the new contents, and finally firing this delta.

If the working copy hasn't changed, then no problem will be detected, this is equivalent to IWorkingCopy#reconcile(false, null).

Compilation problems found in the new contents are notified through the IProblemRequestor interface which was passed at creation, and no longer as transient markers. Therefore this API will return null.

Note: Since 3.0 added/removed/changed inner types generate change deltas.


exception:
  JavaModelException - if the contents of the original elementcannot be accessed. Reasons include:
  • The original Java element does not exist (ELEMENT_DOES_NOT_EXIST)
nullICompilationUnit.reconcile(intbooleanWorkingCopyOwnerIProgressMonitor)



reconcile
void reconcile(boolean forceProblemDetection, IProgressMonitor monitor) throws JavaModelException(Code)
Reconciles the contents of this working copy. It performs the reconciliation by locally caching the contents of the working copy, updating the contents, then creating a delta over the cached contents and the new contents, and finally firing this delta.

The boolean argument allows to force problem detection even if the working copy is already consistent.

Compilation problems found in the new contents are notified through the IProblemRequestor interface which was passed at creation, and no longer as transient markers. Therefore this API answers nothing.

Note: Since 3.0 added/removed/changed inner types generate change deltas.


Parameters:
  forceProblemDetection - boolean indicating whether problem should be recomputedeven if the source hasn't changed.
Parameters:
  monitor - a progress monitor
exception:
  JavaModelException - if the contents of the original elementcannot be accessed. Reasons include:
  • The original Java element does not exist (ELEMENT_DOES_NOT_EXIST)

since:
   2.0ICompilationUnit.reconcile(intbooleanWorkingCopyOwnerIProgressMonitor)



restore
void restore() throws JavaModelException(Code)
Restores the contents of this working copy to the current contents of this working copy's original element. Has no effect if this element is not a working copy.

Note: This is the inverse of committing the content of the working copy to the original element with commit(boolean, IProgressMonitor).
exception:
  JavaModelException - if the contents of the original elementcannot be accessed. Reasons include:

  • The original Java element does not exist (ELEMENT_DOES_NOT_EXIST)
ICompilationUnit.restore



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.