Java Doc for Item.java in  » 6.0-JDK-Modules » jsr-283 » javax » jcr » 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 » 6.0 JDK Modules » jsr 283 » javax.jcr 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.jcr.Item

Item
public interface Item (Code)
The Item is the base interface of Node and Property .




Method Summary
public  voidaccept(ItemVisitor visitor)
     Accepts an ItemVistor.
public  ItemgetAncestor(int depth)
     Returns the ancestor of the specified depth. An ancestor of depth x is the Item that is x levels down along the path from the root node to this Item.
  • depth = 0 returns the root node.
  • depth = 1 returns the child of the root node along the path to this Item.
  • depth = 2 returns the grandchild of the root node along the path to this Item.
  • And so on to depth = n, where n is the depth of this Item, which returns this Item itself.
If depth > n is specified then a ItemNotFoundException is thrown.


Parameters:
  depth - An integer, 0 <= depth <= n where n is the depthof this Item.

public  intgetDepth()
     Returns the depth of this Item in the workspace tree.
public  StringgetName()
     Returns the name of this Item.
public  NodegetParent()
     Returns the parent of this Item. The parent of this Item.
throws:
  ItemNotFoundException - if there is no parent.
public  StringgetPath()
     Returns the absolute path to this item.
public  SessiongetSession()
     Returns the Session through which this Item was acquired. Every Item can ultimately be traced back through a series of method calls to the call Session.getRootNode , Session.getItem or Session.getNodeByUUID .
public  booleanisModified()
     Returns true if this Item has been saved but has subsequently been modified through the current session and therefore the state of this item as recorded in the session differs from the state of this item as saved.
public  booleanisNew()
     Returns true if this is a new item, meaning that it exists only in transient storage on the Session and has not yet been saved.
public  booleanisNode()
     Indicates whether this Item is a Node or a Property.
public  booleanisSame(Item otherItem)
     Returns true if this Item object (the Java object instance) represents the same actual workspace item as the object otherItem.

Two Item objects represent the same workspace item if all the following are true:

  • Both objects were acquired through Session objects that were created by the same Repository object.
  • Both objects were acquired through Session objects bound to the same repository workspace.
  • The objects are either both Node objects or both Property objects.
  • If they are Node objects, they have the same correspondence identifier. Note that this is the identifier used to determine whether two nodes in different workspaces correspond but obviously it is also true that any node has the same correspondence identifier as itself.
public  voidrefresh(boolean keepChanges)
     If keepChanges is false, this method discards all pending changes currently recorded in this Session that apply to this Item or any of its descendants (that is, the subtree rooted at this Item)and returns all items to reflect the current saved state.
public  voidremove()
     Removes this item (and its subtree).

To persist a removal, a save must be performed that includes the (former) parent of the removed item within its scope.

If a node with same-name siblings is removed, this decrements by one the indices of all the siblings with indices greater than that of the removed node.

public  voidsave()
     Validates all pending changes currently recorded in this Session that apply to this Item or any of its descendants (that is, the subtree rooted at this Item).



Method Detail
accept
public void accept(ItemVisitor visitor) throws RepositoryException(Code)
Accepts an ItemVistor. Calls the appropriate ItemVistor visit method of the according to whether this Item is a Node or a Property.
Parameters:
  visitor - The ItemVisitor to be accepted.
throws:
  RepositoryException - if an error occurs.



getAncestor
public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException(Code)
Returns the ancestor of the specified depth. An ancestor of depth x is the Item that is x levels down along the path from the root node to this Item.
  • depth = 0 returns the root node.
  • depth = 1 returns the child of the root node along the path to this Item.
  • depth = 2 returns the grandchild of the root node along the path to this Item.
  • And so on to depth = n, where n is the depth of this Item, which returns this Item itself.
If depth > n is specified then a ItemNotFoundException is thrown.


Parameters:
  depth - An integer, 0 <= depth <= n where n is the depthof this Item. The ancestor of thisItem at the specified depth.
throws:
  ItemNotFoundException - if depth < 0 ordepth > n where n is the is the depth ofthis item.
throws:
  AccessDeniedException - if the current session does not havesufficient access rights to retrieve the specified node.
throws:
  RepositoryException - if another error occurs.




getDepth
public int getDepth() throws RepositoryException(Code)
Returns the depth of this Item in the workspace tree. Returns the depth below the root node of this Item (counting this Item itself).
  • The root node returns 0.
  • A property or child node of the root node returns 1.
  • A property or child node of a child node of the root returns 2.
  • And so on to this Item.
The depth of this Item in the workspace hierarchy.
throws:
  RepositoryException - if an error occurs.



getName
public String getName() throws RepositoryException(Code)
Returns the name of this Item. The name of an item is the last element in its path, minus any square-bracket index that may exist. If this Item is the root node of the workspace (i.e., if this.getDepth() == 0), an empty string will be returned.

the (or a) name of this Item or an empty stringif this Item is the root node.
throws:
  RepositoryException - if an error occurs.




getParent
public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException(Code)
Returns the parent of this Item. The parent of this Item.
throws:
  ItemNotFoundException - if there is no parent. This only happensif this item is the root node of a workspace.
throws:
  AccessDeniedException - if the current session does not havesufficient access rights to retrieve the parent of this item.
throws:
  RepositoryException - if another error occurs.



getPath
public String getPath() throws RepositoryException(Code)
Returns the absolute path to this item. If the path includes items that are same-name sibling nodes properties then those elements in the path will include the appropriate "square bracket" index notation (for example, /a/b[3]/c). the path of this Item.
throws:
  RepositoryException - if an error occurs.



getSession
public Session getSession() throws RepositoryException(Code)
Returns the Session through which this Item was acquired. Every Item can ultimately be traced back through a series of method calls to the call Session.getRootNode , Session.getItem or Session.getNodeByUUID . This method returns that Session object. the Session through which this Item wasacquired.
throws:
  RepositoryException - if an error occurs.



isModified
public boolean isModified()(Code)
Returns true if this Item has been saved but has subsequently been modified through the current session and therefore the state of this item as recorded in the session differs from the state of this item as saved. Within a transaction, isModified on an Item may return false (because the Item has been saved since the modification) even if the modification in question is not in persistent storage (because the transaction has not yet been committed).

Note that in level 1 (that is, read-only) implementations, this method will always return false. true if this item is modified; false otherwise.




isNew
public boolean isNew()(Code)
Returns true if this is a new item, meaning that it exists only in transient storage on the Session and has not yet been saved. Within a transaction, isNew on an Item may return false (because the item has been saved) even if that Item is not in persistent storage (because the transaction has not yet been committed).

Note that if an item returns true on isNew, then by definition is parent will return true on isModified.

Note that in level 1 (that is, read-only) implementations, this method will always return false. true if this item is new; false otherwise.




isNode
public boolean isNode()(Code)
Indicates whether this Item is a Node or a Property. Returns true if this Item is a Node; Returns false if this Item is a Property. true if this Item is aNode, false if it is a Property.



isSame
public boolean isSame(Item otherItem) throws RepositoryException(Code)
Returns true if this Item object (the Java object instance) represents the same actual workspace item as the object otherItem.

Two Item objects represent the same workspace item if all the following are true:

  • Both objects were acquired through Session objects that were created by the same Repository object.
  • Both objects were acquired through Session objects bound to the same repository workspace.
  • The objects are either both Node objects or both Property objects.
  • If they are Node objects, they have the same correspondence identifier. Note that this is the identifier used to determine whether two nodes in different workspaces correspond but obviously it is also true that any node has the same correspondence identifier as itself. Hence, this identifier is used here to determine whether two different Java Node objects actually represent the same workspace node.
  • If they are Property objects they have identical names and isSame is true of their parent nodes.
This method does not compare the states of the two items. For example, if two Item objects representing the same actual workspace item have been retrieved through two different sessions and one has been modified, then this method will still return true when comparing these two objects. Note that if two Item objects representing the same workspace item are retrieved through the same session they will always reflect the same state (see section 5.1.3 Reflecting Item State in the JSR 283 specification document) so comparing state is not an issue.
Parameters:
  otherItem - the Item object to be tested for identity with this Item. true if this Item object and otherItem represent the same actual repositoryitem; false otherwise.
throws:
  RepositoryException - if an error occurs.



refresh
public void refresh(boolean keepChanges) throws InvalidItemStateException, RepositoryException(Code)
If keepChanges is false, this method discards all pending changes currently recorded in this Session that apply to this Item or any of its descendants (that is, the subtree rooted at this Item)and returns all items to reflect the current saved state. Outside a transaction this state is simple the current state of persistent storage. Within a transaction, this state will reflect persistent storage as modified by changes that have been saved but not yet committed.

If keepChanges is true then pending change are not discarded but items that do not have changes pending have their state refreshed to reflect the current saved state, thus revealing changes made by other sessions.

An InvalidItemStateException is thrown if this Item object represents a workspace item that has been removed (either by this session or another).
Parameters:
  keepChanges - a boolean
throws:
  InvalidItemStateException - if thisItem object represents a workspace item that has beenremoved (either by this session or another).
throws:
  RepositoryException - if another error occurs.




remove
public void remove() throws VersionException, LockException, ConstraintViolationException, RepositoryException(Code)
Removes this item (and its subtree).

To persist a removal, a save must be performed that includes the (former) parent of the removed item within its scope.

If a node with same-name siblings is removed, this decrements by one the indices of all the siblings with indices greater than that of the removed node. In other words, a removal compacts the array of same-name siblings and causes the minimal re-numbering required to maintain the original order but leave no gaps in the numbering.

A ReferentialIntegrityException will be thrown on save if this item or an item in its subtree is currently the target of a REFERENCE property located in this workspace but outside this item's subtree and the current Session has read access to that REFERENCE property.

An AccessDeniedException will be thrown on save if this item or an item in its subtree is currently the target of a REFERENCE property located in this workspace but outside this item's subtree and the current Session does not have read access to that REFERENCE property.

A ConstraintViolationException will be thrown either immediately or on save, if removing this item would violate a node type or implementation-specific constraint. Implementations may differ on when this validation is performed.

A VersionException will be thrown either immediately or on save, if the parent node of this item is versionable and checked-in or is non-versionable but its nearest versionable ancestor is checked-in. Implementations may differ on when this validation is performed.

A LockException will be thrown either immediately or on save if a lock prevents the removal of this item. Implementations may differ on when this validation is performed.
throws:
  VersionException - if the parent node of this item is versionable and checked-inor is non-versionable but its nearest versionable ancestor is checked-in and thisimplementation performs this validation immediately instead of waiting until save.
throws:
  LockException - if a lock prevents the removal of this item and thisimplementation performs this validation immediately instead of waiting until save.
throws:
  ConstraintViolationException - if removing the specified item would violate a node type orimplementation-specific constraint and this implementation performs this validation immediatelyinstead of waiting until save.
throws:
  RepositoryException - if another error occurs.




save
public void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException, InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException, NoSuchNodeTypeException, RepositoryException(Code)
Validates all pending changes currently recorded in this Session that apply to this Item or any of its descendants (that is, the subtree rooted at this Item). If validation of all pending changes succeeds, then this change information is cleared from the Session. If the save occurs outside a transaction, the changes are persisted and thus made visible to other Sessions. If the save occurs within a transaction, the changes are not persisted until the transaction is committed.

If validation fails, then no pending changes are saved and they remain recorded on the Session. There is no best-effort or partial save.

The item in persistent storage to which a transient item is saved is determined by matching identifiers and paths.

An AccessDeniedException will be thrown if any of the changes to be persisted would violate the access privileges of this Session.

If any of the changes to be persisted would cause the removal of a node that is currently the target of a REFERENCE property then a ReferentialIntegrityException is thrown, provided that this Session has read access to that REFERENCE property. If, on the other hand, this Session does not have read access to the REFERENCE property in question, then an AccessDeniedException is thrown instead.

An ItemExistsException will be thrown if any of the changes to be persisted would be prevented by the presence of an already existing item in the workspace.

A ConstraintViolationException will be thrown if any of the changes to be persisted would violate a node type restriction. Additionally, a repository may use this exception to enforce implementation- or configuration-dependant restrictions.

An InvalidItemStateException is thrown if any of the changes to be persisted conflicts with a change already persisted through another session and the implementation is such that this conflict can only be detected at save-time and therefore was not detected earlier, at change-time.

A VersionException is thrown if the save would make a result in a change to persistent storage that would violate the read-only status of a checked-in node.

A LockException is thrown if the save would result in a change to persistent storage that would violate a lock.

A NoSuchNodeTypeException is thrown if the save would result in the addition of a node with an unrecognized node type.

A RepositoryException will be thrown if another error occurs.
throws:
  AccessDeniedException - if any of the changes to be persisted would violatethe access privileges of the this Session. Also thrown if any of thechanges to be persisted would cause the removal of a node that is currentlyreferenced by a REFERENCE property that this Sessiondoes not have read access to.
throws:
  ItemExistsException - if any of the changesto be persisted would be prevented by the presence of an already existingitem in the workspace.
throws:
  ConstraintViolationException - if any of the changes to be persisted wouldviolate a node type or restriction. Additionally, a repository may use thisexception to enforce implementation- or configuration-dependent restrictions.
throws:
  InvalidItemStateException - if any of thechanges to be persisted conflicts with a change already persistedthrough another session and the implementation is such that thisconflict can only be detected at save-time and therefore was notdetected earlier, at change-time.
throws:
  ReferentialIntegrityException - if any of thechanges to be persisted would cause the removal of a node that is currentlyreferenced by a REFERENCE property that this Sessionhas read access to.
throws:
  VersionException - if the save would make a result ina change to persistent storage that would violate the read-only status of achecked-in node.
throws:
  LockException - if the save would result in achange to persistent storage that would violate a lock.
throws:
  NoSuchNodeTypeException - if the save would result in theaddition of a node with an unrecognized node type.
throws:
  RepositoryException - if another error occurs.




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