/Users/detro/workspace-nb/JAEBI/src/java/org/jaebi/server/service/XRequestCommand.java

Vai alla documentazione di questo file.
00001 /*
00002  * XRequestCommand.java
00003  *
00004  * Created on June 5, 2005, 3:06 PM
00005  * Created by Detro - 566/2145
00006  */
00007 
00008 package org.jaebi.server.service;
00009 
00010 import java.util.ArrayList;
00011 import java.util.HashMap;
00012 import java.util.Iterator;
00013 import java.util.List;
00014 
00015 import org.jaebi.server.service.exception.CommandExecException;
00016 import org.jaebi.server.service.exception.XRequestCommandInitException;
00017 import org.jaebi.server.service.xml.JAXBMarshallerWrapper;
00018 import org.jaebi.server.service.xml.JAXBMarshallerWrapperImpl;
00019 import org.jaebi.server.service.xml.JAXBXResponseFactory;
00020 import org.jaebi.server.service.xml.exception.JAXBMarshallerWrapperInitException;
00021 import org.jaebi.server.service.xml.exception.JAXBMarshallerWrapperMarshallException;
00022 import org.jaebi.server.service.xml.xrequest.Column;
00023 import org.jaebi.server.service.xml.xrequest.Xrequest;
00024 
00051  abstract public class XRequestCommand extends Command {
00054     protected static final JAXBXResponseFactory xresponseFactory = 
00055             new JAXBXResponseFactory();
00056      
00058     protected final BackEndHandlerImpl backEndHandler;
00059     
00062     protected final Xrequest xrequestObj;
00063     
00066     private ArrayList columnsName = null;
00067     
00071     private HashMap columnsValue = null;
00072     
00075     private ArrayList whereColumnsName = null;
00076     
00080     private HashMap whereColumnsValue = null;
00081     
00082     protected static String exceptionPrefix = "[XRequestCommand Exception]: ";
00083     
00089     public XRequestCommand(Xrequest newXrequestObj, BackEndHandlerImpl newBackEndHandlerImpl) 
00090         throws XRequestCommandInitException {
00091         
00092         if ( newXrequestObj == null || newBackEndHandlerImpl == null ) {
00093             throw new XRequestCommandInitException(exceptionPrefix + 
00094                     "Init parameter error\n");
00095         }
00096         xrequestObj = newXrequestObj;
00097         backEndHandler = newBackEndHandlerImpl;
00098         
00099     }
00100     
00101     // Ereditato da Command
00102     public abstract Object execute() throws CommandExecException; 
00103     
00107     public String getType() {
00108         return xrequestObj.getType();
00109     }
00110     
00116     public String getAffectedTable() {
00117         return xrequestObj.getTable();
00118     }
00119     
00130     private ArrayList getNameFromColumnList(List columns) {
00131         ArrayList result = new ArrayList();
00132         if ( columns != null ) {
00133             Iterator iter = columns.iterator();
00134             Column column = null;
00135 
00136             while ( iter.hasNext() ) {
00137                 column = (Column)iter.next();
00138                 result.add( column.getName() );
00139             }
00140         }
00141 
00142         return result;
00143     }
00144     
00156     private HashMap getValueFromColumnList(List columns) {
00157         HashMap result = new HashMap();
00158         if ( columns != null ) {
00159             Iterator iter = columns.iterator();
00160             Column column = null;
00161 
00162             while ( iter.hasNext() ) {
00163                 column = (Column)iter.next();
00164                 result.put(column.getName(), column.getValue());
00165             }
00166         }
00167         
00168         return result;
00169     }
00170     
00176     public ArrayList getColumnsName() {
00177         if ( columnsName == null ) {
00178             if ( xrequestObj.getColumns() != null ) {
00179                 columnsName = getNameFromColumnList( 
00180                         xrequestObj.getColumns().getColumn() ); // Caching...
00181             } else
00182                 columnsName = new ArrayList();
00183         }
00184         return columnsName; // Using Cache...
00185     }
00186     
00196     public HashMap getColumnsValue() {
00197         if ( columnsValue == null ) {
00198             if ( xrequestObj.getColumns() != null ) {
00199                 columnsValue = getValueFromColumnList( 
00200                         xrequestObj.getColumns().getColumn() ); // Caching...
00201             } else
00202                 columnsValue = new HashMap();
00203         }
00204         return columnsValue; // Using Cache...
00205     }
00206     
00212     public ArrayList getWhereColumnsName() {
00213         if ( whereColumnsName == null ) {
00214             if ( xrequestObj.getWhere() != null ) {
00215                 whereColumnsName = getNameFromColumnList( 
00216                         xrequestObj.getWhere().getColumn() ); // Caching...
00217             } else
00218                 whereColumnsName = new ArrayList();
00219         }
00220         return whereColumnsName; // Using Cache...
00221     }
00222     
00231     public HashMap getWhereColumnsValue() {
00232         if ( whereColumnsValue == null ) {
00233             if ( xrequestObj.getWhere() != null ) {
00234                 whereColumnsValue = getValueFromColumnList( 
00235                         xrequestObj.getWhere().getColumn() ); // Caching...
00236             } else
00237                 whereColumnsValue = new HashMap();
00238         }
00239         return whereColumnsValue; // Using Cache...
00240     }
00241     
00242     public String toString() {
00243         JAXBMarshallerWrapper marshWrap = null;
00244         String result = null;
00245         
00246         try {
00247             marshWrap = new JAXBMarshallerWrapperImpl("org.jaebi.server.service.xml.xrequest");
00248             marshWrap.setFormattedMarshalling(true);
00249             result = marshWrap.marshall( xrequestObj );
00250         } catch ( JAXBMarshallerWrapperMarshallException e ) {
00251             return "<XRequestCommand> toString conversion (marshalling) exception:\n" + e;
00252         } catch ( JAXBMarshallerWrapperInitException e ) {
00253             return "<XRequestCommand> toString conversion (Marshall Wrapper Init) exception:\n" + e;
00254         }
00255         
00256         return result;
00257     }
00258 }

Generato il Mon Jun 27 22:50:38 2005 per JAEBI - JAva Enterprice BackEnd Interfacement da  doxygen 1.4.3