Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX -
Contents Index PreviousNext

Part 2 Developing Applications by APIs> Chapter 9 Developing Java Applications> 9.3 How to Use Java APIs> 9.3.2 Data Searches

9.3.2.6 Using Record IDs to Obtain Entire XML Documents

When searching for a particular XML document, do not obtain the entire document immediately. Instead, start by obtaining the partial information that can effectively identify the document.

The user can then use this partial information to pick out the desired XML document and obtain detailed information. To extract an entire XML document, use the record ID that is returned when the partial information is extracted. Using a record ID enables desired entire XML documents to be extracted.

The following diagram shows the process for using record IDs to obtain an entire XML document.

[Figure 9-8 Flow of the Process for Using Record IDs to Obtain an Entire XML Document]

mark1Sample Code

ShunConnection con = new ShunConnection();

ShunPreparedRecordID prid = con.prepareSearchRecordID();       (1)
prid.add(recordID);                                            (2)
ShunResultSet rs = prid.searchByRecordID();                    (3)
while (rs.next()) {                                            (4)
  System.out.println("[Result] = " + rs.getString());          (4)
}
rs.close();                                                    (5)
prid.close();                                                  (5)

con.close();

mark2(1) Create a ShunPreparedRecordID Object

Use the prepareSearchRecordID method to create a ShunPreparedRecordID object.

mark2(2) Specify the Record ID

Use the add method to specify the record ID. Record IDs can be obtained using the getRecordID method.

Multiple record IDs can be specified with the add method. Any existing record IDs will be overwritten if they are specified again.

By specifying multiple record IDs with the add method, multiple XML documents can be obtained at once.

mark2(3) Execute the Search (Create a ShunResultSet Object)

Execute the search using the searchByRecordID method. A ShunResultSet object will be created to hold the results of the search.

mark2(4) Extract the Results of the Search

Always invoke the next method before extracting the results of the search. The next method returns true if there is still more data that can be extracted and false otherwise.

Different methods can be used to extract XML documents for different objectives. The following table shows the methods that can be used.

[Table 9-4 Methods that Can be Used to Extract XML Documents]

Method

Function

getString

Extracts XML documents as String objects.

getStream

Extracts XML documents as InputStream objects.

mark2(5) Release the ShunResultSet Object and the ShunPreparedRecordID Object

Use the close methods of the ShunResultSet object and the ShunPreparedRecordID object to release these objects when they are no longer required.

mark1Sample Codes for Studio

The following sample code shows how to use a record ID to extract an entire XML document in the case of the business class and the Shunsaku access class.

Business Class

ShunConnection con = new ShunConnection();

ShunsakuAccessController controller = new ShunsakuAccessController(con);
Object[] resultData = controller.detail(recordID);
controller.close();

con.close();

Shunsaku Access Class

public Object[] detail(String recordID) throws ShunException {
   Object[] resultData = null;

   ShunPreparedRecordID prid = con.prepareSearchRecordID();          (1)
   prid.add(recordID);                                               (2)

   ShunResultSet rs = prid.searchByRecordID();                       (3)
   try { 
      resultData = paeseResultSet(rs);                               (4)
   }   finally {
      rs.close();                                                    (5)
   }
   prid.close();                                                     (5)
   
   return resultData;
}

Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006