Java Doc for OrdinalManager.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » cmf » dam » 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 » Web Framework » rife 1.6.1 » com.uwyn.rife.cmf.dam 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.uwyn.rife.cmf.dam.OrdinalManager

OrdinalManager
public class OrdinalManager implements Cloneable(Code)
This class makes it possible to easily manage an integer ordinal column that is typically used to determine the order of the rows in a specific table.

The basic version manages the ordinals for the entire table, but it's also possible to create an OrdinalManager that uses several independent ranges of ordinals according to a restricting integer column.

For example, consider the following 'article' table:

id          INT
 categoryId  INT
 ordinal     INT
 name        VARCHAR(30)

with the following rows:

 id | categoryId | ordinal | name
 ----+------------+---------+-----------------------
 2 |          1 |       0 | some article
 0 |          1 |       1 | another one
 3 |          1 |       2 | boom boom
 1 |          2 |       0 | this is yet an article
 5 |          2 |       1 | an article for you
 4 |          3 |       0 | our latest article
 6 |          3 |       1 | important one

You can clearly see three independent ordinal ranges according to the categoryId column.

The OrdinalManager allows you to easily change the order of the articles by moving them up and down with the provided methods: OrdinalManager.move(Direction,int) move , OrdinalManager.up(int) up and OrdinalManager.down(int) down . It's also possible to do more complex manipulations by using the lower level methods: OrdinalManager.free(int) free , OrdinalManager.update(int,int) update , OrdinalManager.tighten() tighten and OrdinalManager.obtainInsertOrdinal()obtainInsertOrdinal .
author:
   Geert Bevin (gbevin[remove] at uwyn dot com)
version:
   $Revision: 3634 $
since:
   1.0


Inner Class :public static class Direction extends EnumClass

Field Summary
final public static  DirectionDOWN
     Has to be used to indicate an downwards direction for the OrdinalManager.move(Direction,int) move method.
final public static  DirectionUP
     Has to be used to indicate an upwards direction for the OrdinalManager.move(Direction,int) move method.

Constructor Summary
public  OrdinalManager(Datasource datasource, String table, String ordinalColumn)
     Creates a new OrdinalManager that manages ordinals globally for the specified table.
public  OrdinalManager(Datasource datasource, String table, String ordinalColumn, String restrictColumn)
     Creates a new OrdinalManager that manages ordinals for the specified table in independent ranges according to a restricting integer column.

Method Summary
public  Objectclone()
     Simply clones the instance with the default clone method.
public  booleandown(int ordinal)
     Moves a row with a specific ordinal downwards within the entire table.
public  booleandown(long restrictId, int ordinal)
     Moves a row with a specific ordinal downwards within the range restricted by the provided ID.
public  booleanfree(int ordinal)
     Frees up a slot for the specified ordinal within the entire table., this is done by incrementing everything after it by 1 to make space.
public  booleanfree(long restrictId, int ordinal)
     Frees up a slot for the specified ordinal within the range restricted by the provided ID, this is done by incrementing everything after it by 1 to make space.
public  StringgetOrdinalColumn()
     Retrieves the name of the ordinal column.
public  StringgetRestrictColumn()
     Retrieves the name of the restricting column.
public  StringgetTable()
     Retrieves the name of the table of this OrdinalManager.
public  booleanmove(Direction direction, int ordinal)
     Moves the position of a row with a specific ordinal within the entire table.
public  booleanmove(Direction direction, long restrictId, int ordinal)
     Moves the position of a row with a specific ordinal within the range restricted by the provided ID.
public  booleanmove(int fromOrdinal, int toOrdinal)
     Moves a row with a specific ordinal to the location of another ordinal within the entire table.
public  booleanmove(long restrictId, int fromOrdinal, int toOrdinal)
     Moves a row with a specific ordinal to the location of another ordinal within the range restricted by the provided ID.
public  intobtainInsertOrdinal()
     Returns the next freely available ordinal that can be used to insert a new row behind all the other rows in the entire table.
public  intobtainInsertOrdinal(long restrictId)
     Returns the next freely available ordinal that can be used to insert a new row behind all the other rows in the range restricted by the provided ID.
public  booleantighten()
     Tightens the series of ordinal within the entire table so that no spaces are present in between the ordinals.
public  booleantighten(long restrictId)
     Tightens the series of ordinal within the range restricted by the provided ID so that no spaces are present in between the ordinals.
public  booleanup(int ordinal)
     Moves a row with a specific ordinal upwards within the entire table.
public  booleanup(long restrictId, int ordinal)
     Moves a row with a specific ordinal upwards within the range restricted by the provided ID.
public  booleanupdate(int currentOrdinal, int newOrdinal)
     Changes the ordinal of a certain row to a new value.
public  booleanupdate(long restrictId, int currentOrdinal, int newOrdinal)
     Changes the ordinal of a certain row with a specific restriction ID to a new value.

Field Detail
DOWN
final public static Direction DOWN(Code)
Has to be used to indicate an downwards direction for the OrdinalManager.move(Direction,int) move method.



UP
final public static Direction UP(Code)
Has to be used to indicate an upwards direction for the OrdinalManager.move(Direction,int) move method.




Constructor Detail
OrdinalManager
public OrdinalManager(Datasource datasource, String table, String ordinalColumn)(Code)
Creates a new OrdinalManager that manages ordinals globally for the specified table.
Parameters:
  datasource - the datasource where the table is accessible
Parameters:
  table - the name of the table that will be managed
Parameters:
  ordinalColumn - the name of the column that contains the integerordinals
since:
   1.0



OrdinalManager
public OrdinalManager(Datasource datasource, String table, String ordinalColumn, String restrictColumn)(Code)
Creates a new OrdinalManager that manages ordinals for the specified table in independent ranges according to a restricting integer column.
Parameters:
  datasource - the datasource where the table is accessible
Parameters:
  table - the name of the table that will be managed
Parameters:
  ordinalColumn - the name of the column that contains the integerordinals
Parameters:
  restrictColumn - the name of the column whose values willpartition the ordinals in independent ranges
since:
   1.0




Method Detail
clone
public Object clone()(Code)
Simply clones the instance with the default clone method. This creates a shallow copy of all fields and the clone will in fact just be another reference to the same underlying data. The independence of each cloned instance is consciously not respected since they rely on resources that can't be cloned.
since:
   1.0



down
public boolean down(int ordinal)(Code)
Moves a row with a specific ordinal downwards within the entire table.
Parameters:
  ordinal - the ordinal of the row that has to be moved true if the move was executed successfully; or

false if this wasn't the case
See Also:   OrdinalManager.down(long,int)
since:
   1.0




down
public boolean down(long restrictId, int ordinal)(Code)
Moves a row with a specific ordinal downwards within the range restricted by the provided ID.
Parameters:
  restrictId - the restriction ID value
Parameters:
  ordinal - the ordinal of the row that has to be moved true if the move was executed successfully; or

false if this wasn't the case
See Also:   OrdinalManager.down(int)
since:
   1.0




free
public boolean free(int ordinal)(Code)
Frees up a slot for the specified ordinal within the entire table., this is done by incrementing everything after it by 1 to make space.

So for example issuing the method free(1) on the following table:

 id | ordinal | name
 ----+---------+-----------------------
 2 |       0 | some article
 0 |       1 | another one
 1 |       2 | this is yet an article

will result in:

 id | ordinal | name
 ----+---------+-----------------------
 2 |       0 | some article
 0 |       2 | another one
 1 |       3 | this is yet an article

Parameters:
  ordinal - an integer representing the ordinal to free true if the slot was freed up correctly; or

false if the operation wasn't possible
See Also:   OrdinalManager.free(long,int)
since:
   1.0




free
public boolean free(long restrictId, int ordinal)(Code)
Frees up a slot for the specified ordinal within the range restricted by the provided ID, this is done by incrementing everything after it by 1 to make space.

So for example issuing the method free(2, 0) on the following table:

 id | categoryId | ordinal | name
 ----+------------+---------+-----------------------
 2 |          1 |       0 | some article
 0 |          1 |       1 | another one
 3 |          1 |       2 | boom boom
 1 |          2 |       0 | this is yet an article
 5 |          2 |       1 | an article for you
 4 |          3 |       0 | our latest article
 6 |          3 |       1 | important one

will result into:

 id | categoryId | ordinal | name
 ----+------------+---------+-----------------------
 2 |          1 |       0 | some article
 0 |          1 |       1 | another one
 3 |          1 |       2 | boom boom
 1 |          2 |       1 | this is yet an article
 5 |          2 |       2 | an article for you
 4 |          3 |       0 | our latest article
 6 |          3 |       1 | important one

Parameters:
  restrictId - the id by which to restrict with
Parameters:
  ordinal - an int representation the ordinal to free true if the slot was freed up correctly; or

false if the operation wasn't possible
See Also:   OrdinalManager.free(int)
since:
   1.0




getOrdinalColumn
public String getOrdinalColumn()(Code)
Retrieves the name of the ordinal column. the name of the ordinal column
since:
   1.0



getRestrictColumn
public String getRestrictColumn()(Code)
Retrieves the name of the restricting column. the name of the restricting column; or

null if this OrdinalManager manages thetable globally
since:
   1.0




getTable
public String getTable()(Code)
Retrieves the name of the table of this OrdinalManager. the name of the table
since:
   1.0



move
public boolean move(Direction direction, int ordinal)(Code)
Moves the position of a row with a specific ordinal within the entire table.
Parameters:
  direction - the direction in which to move: OrdinalManager.UP OrdinalManager.UP or OrdinalManager.DOWNOrdinalManager.DOWN
Parameters:
  ordinal - the ordinal of the row that has to be moved true if the move was executed successfully; or

false if this wasn't the case
See Also:   OrdinalManager.move(Direction,long,int)
since:
   1.0




move
public boolean move(Direction direction, long restrictId, int ordinal)(Code)
Moves the position of a row with a specific ordinal within the range restricted by the provided ID.
Parameters:
  direction - the direction in which to move: OrdinalManager.UP OrdinalManager.UP or OrdinalManager.DOWNOrdinalManager.DOWN
Parameters:
  restrictId - the restriction ID value
Parameters:
  ordinal - the ordinal of the row that has to be moved true if the move was executed successfully; or

false if this wasn't the case
See Also:   OrdinalManager.move(Direction,int)
since:
   1.0




move
public boolean move(int fromOrdinal, int toOrdinal)(Code)
Moves a row with a specific ordinal to the location of another ordinal within the entire table.
Parameters:
  fromOrdinal - the ordinal of the row that has to be moved
Parameters:
  toOrdinal - the ordinal of the row where the from row has will beput above true if the move was executed successfully; or

false if this wasn't the case
See Also:   OrdinalManager.down(int)
since:
   1.0




move
public boolean move(long restrictId, int fromOrdinal, int toOrdinal)(Code)
Moves a row with a specific ordinal to the location of another ordinal within the range restricted by the provided ID.
Parameters:
  restrictId - the restriction ID value
Parameters:
  fromOrdinal - the ordinal of the row that has to be moved
Parameters:
  toOrdinal - the ordinal of the row where the from row has will beput above true if the move was executed successfully; or

false if this wasn't the case
See Also:   OrdinalManager.down(int)
since:
   1.0




obtainInsertOrdinal
public int obtainInsertOrdinal()(Code)
Returns the next freely available ordinal that can be used to insert a new row behind all the other rows in the entire table.

So for example issuing the method obtainInsertOrdinal() on the following table:

 id | ordinal | name
 ----+---------+-----------------------
 2 |       0 | some article
 0 |       1 | another one
 1 |       2 | this is yet an article

Will return the value 3. the requested ordinal; or

0 if no ordinals are present within the table yet
See Also:   OrdinalManager.obtainInsertOrdinal(long)
since:
   1.0




obtainInsertOrdinal
public int obtainInsertOrdinal(long restrictId)(Code)
Returns the next freely available ordinal that can be used to insert a new row behind all the other rows in the range restricted by the provided ID.

So for example issuing the method obtainInsertOrdinal(3) on the following table:

 id | categoryId | ordinal | name
 ----+------------+---------+-----------------------
 2 |          1 |       0 | some article
 0 |          1 |       1 | another one
 3 |          1 |       2 | boom boom
 1 |          2 |       0 | this is yet an article
 5 |          2 |       1 | an article for you
 4 |          3 |       0 | our latest article
 6 |          3 |       1 | important one

Will return the value 2.
Parameters:
  restrictId - the id by which to restrict with the requested ordinal; or

0 if no ordinals are present within the range yet
See Also:   OrdinalManager.obtainInsertOrdinal()
since:
   1.0




tighten
public boolean tighten()(Code)
Tightens the series of ordinal within the entire table so that no spaces are present in between the ordinals.

So for example issuing the method tighten() on the following table:

 id | ordinal | name
 ----+---------+-----------------------
 2 |       0 | some article
 0 |       2 | another one
 1 |       5 | this is yet an article

will result in:

 id | ordinal | name
 ----+---------+-----------------------
 2 |       0 | some article
 0 |       1 | another one
 1 |       2 | this is yet an article
true if the tightening was executed correctly; or

false if the operation wasn't possible
See Also:   OrdinalManager.tighten(long)
since:
   1.0




tighten
public boolean tighten(long restrictId)(Code)
Tightens the series of ordinal within the range restricted by the provided ID so that no spaces are present in between the ordinals.

So for example issuing the method tighten(2) on the following table:

 id | categoryId | ordinal | name
 ----+------------+---------+-----------------------
 2 |          1 |       1 | some article
 0 |          1 |       2 | another one
 3 |          1 |       7 | boom boom
 1 |          2 |       4 | this is yet an article
 5 |          2 |       8 | an article for you
 4 |          3 |       4 | our latest article
 6 |          3 |       5 | important one

will result in:

 id | categoryId | ordinal | name
 ----+------------+---------+-----------------------
 2 |          1 |       1 | some article
 0 |          1 |       2 | another one
 3 |          1 |       7 | boom boom
 1 |          2 |       0 | this is yet an article
 5 |          2 |       1 | an article for you
 4 |          3 |       4 | our latest article
 6 |          3 |       5 | important one

Parameters:
  restrictId - the id by which to restrict with true if the tightening was executed correctly; or

false if the operation wasn't possible
See Also:   OrdinalManager.tighten()
since:
   1.0




up
public boolean up(int ordinal)(Code)
Moves a row with a specific ordinal upwards within the entire table.
Parameters:
  ordinal - the ordinal of the row that has to be moved true if the move was executed successfully; or

false if this wasn't the case
See Also:   OrdinalManager.up(long,int)
since:
   1.0




up
public boolean up(long restrictId, int ordinal)(Code)
Moves a row with a specific ordinal upwards within the range restricted by the provided ID.
Parameters:
  restrictId - the restriction ID value
Parameters:
  ordinal - the ordinal of the row that has to be moved true if the move was executed successfully; or

false if this wasn't the case
See Also:   OrdinalManager.up(int)
since:
   1.0




update
public boolean update(int currentOrdinal, int newOrdinal)(Code)
Changes the ordinal of a certain row to a new value.

This simply updates the value of the ordinal column and doesn't execute any other logic.
Parameters:
  currentOrdinal - the ordinal of the row that has to be updated
Parameters:
  newOrdinal - the new ordinal value true if the update was executed successfully; or

false if this wasn't the case
See Also:   OrdinalManager.update(long,int,int)
since:
   1.0




update
public boolean update(long restrictId, int currentOrdinal, int newOrdinal)(Code)
Changes the ordinal of a certain row with a specific restriction ID to a new value.

This simply updates the value of the ordinal column and doesn't execute any other logic.
Parameters:
  restrictId - the id by which to restrict with
Parameters:
  currentOrdinal - the ordinal of the row that has to be updated
Parameters:
  newOrdinal - the new ordinal value true if the update was executed successfully; or

false if this wasn't the case
See Also:   OrdinalManager.update(int,int)
since:
   1.0




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

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