com.sun.jump.module.contentstore

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 » j2me » com.sun.jump.module.contentstore 
com.sun.jump.module.contentstore
This package consists of classes that provides the core abstractions for a content store. A content store uses a JUMPStore to persist the content store data.

The following sample code shows, how a store can be implemented on a filesystem. Every node that does not contain JUMPData is represented as a directory in the filesystem and every data node is represented in a single file say data.properties. Each line in the data.properties file contains the following information. data-name,data-type,data-value


  public class FileStoreImpl implements JUMPStore {

     public void createDataNode(String uri, JUMPData jumpData) {

        // get the full path of the file that holds the data for the
        // uri passed.
        File file = uriToDataFile(uri);
        // the data name is the last component of the URI.
        String dataName = getDataName(uri);
        String marshalledData = createMarshalledData(dataName, jumpData);
        OutputStream stream = createOutputStream(file);
        stream.writeString(marshalled);
      
        // The impl might create an instance of JUMPNode containing the jumpData
        // eagerly here, or delay until it is requested by getNode(String uri) 
        // call below.
     }

     public void createNode(String uri) {
        File file = uriToFile(uri);
        file.mkdirs();
     }                  

     public JUMPNode getNode(String uri) {
        // getNode(String) needs to return what the createDataNode() above store
        // if the uri parameter represents a data node.
   
        if (!isDataFile(uri)) {

            // This URI represents non-leaf node.
            // .... then do something to create a JUMPNode representing a List,
            // and return it.

        }  else {    
   
            File file = urlToDataFile(uri);
      
            String name = getDataName(uri);
            InputStream stream = createInputStream(file);
            String marshalledData = stream.readString();
      
            JUMPData data = createUnmarshalledData(marshalledData);
      
            JUMPNode node = createJUMPNode(uri, name, data);
      
            return node;
        }
     }

     public void deleteNode(String uri) {
        File file = uriToFile(uri);
        file.delete();
     }

     public void updateNode(String uri, JUMPData jumpData) {
        // check if the node represented by the uri exists and is data.
        if (!isDataFile(uri) || !exists(uri) ) {
           throw new java.io.IOException("Update failed"); 
        }
 
        // delete the old node and create a node with the new data.
        deleteNode(uri);
        createDataNode(uri, jumpData);
     }
   
     private String createMarshalledData(String dataname, JUMPData data) {
        // Create a representation of JUMPData's content to be written out to the file.
        // This method does not have to process anything in JUMPData data, but merely to
        // come up with a String representation of the JUMPData content that works the
        // opposite way of createUnmarshalledData.  The returned type, String, is also
        // just for the implementation example, and can also be in any other format.
     }

     private JUMPData createUnmarshalledData(String marshalledData) {
        // Creates a JUMPData out of the "marshalledData" representation.
        // This method should just do the opposite of createMarshalledData(JUMPData).
     }
  } 
  
The following sample code shows how a concrete content store can be implemented by extending the JUMPContentStore. The object that the sample stores in the content store is Application which consists of a title and a iconPath. AppRepository has methods to get the Application objects.
  public class Application {
     
     public String getTitle() {
        return title;
     }
     
     public String getIconPath() {
        return iconPath;
     }
  }
  
  public class AppRepository extends JUMPContentStore {
      private static final String ROOT_URI = "./Apps";
      private Class storeClass = JUMPFileStore.class;
      
      
      protected JUMPStore getStore() {
         return JUMPExecutive.getInstance().getModule(this.storeClass);
      }
      
      public Application getApplication(String name) {
          Application app = new Application();
          // get access to the store in a read-only mode
          JUMPStoreHandle storeHandle = openStore(false);
          
          JUMPNode.Data appNode = (JUMPNode.Data)
            storeHandle.getNode(ROOT_URI+"/"+name+"/title");
          app.setTitle(appNode.getString());
          appNode = (JUMPNode.Data)
            storeHandle.getNode(ROOT_URI+"/"+name+"/iconPath");
          app.setIconPath(appNode.getString());
          
          // indicate that we do not need the store any more
          closeStore(storeHandle);
          return app;
      }
  }
  
  
Java Source File NameTypeComment
InMemoryContentStore.javaClass In memory version of JUMPContentStore.
InMemoryStore.javaClass Simple in-memory store.
JUMPContentStore.javaClass JUMPContentStore provides a base class for all content stores in the JUMP system.
JUMPData.javaClass JUMPData encapsulates the value stored in the persistant store.
JUMPNode.javaInterface JUMPNode abstracts the interface to access the data stored in the store.
JUMPStore.javaClass JUMPStore provides methods to access a persistant store.
JUMPStoreFactory.javaClass JUMPStoreFactory is a factory for JUMPStore.
JUMPStoreHandle.javaClass JUMPStoreHandle is a handle to perform operations on a JUMPStore.
JUMPStoreRuntimeException.javaClass JUMPStoreRuntimeException is an unchecked exception to indicate user error while calling JUMP contentstore APIs.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.