Author: vgritsenko Date: Tue Apr 26 09:46:03 2005 New Revision: 164828 URL: http://svn.apache.org/viewcvs?rev=164828&view=rev Log: Use EMPTY_PROPERTIES
Modified: cocoon/blocks/unsupported/web3/trunk/java/org/apache/cocoon/components/web3/impl/DefaultWeb3StreamerImpl.java Modified: cocoon/blocks/unsupported/web3/trunk/java/org/apache/cocoon/components/web3/impl/DefaultWeb3StreamerImpl.java URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/web3/trunk/java/org/apache/cocoon/components/web3/impl/DefaultWeb3StreamerImpl.java?rev=164828&r1=164827&r2=164828&view=diff ============================================================================== --- cocoon/blocks/unsupported/web3/trunk/java/org/apache/cocoon/components/web3/impl/DefaultWeb3StreamerImpl.java (original) +++ cocoon/blocks/unsupported/web3/trunk/java/org/apache/cocoon/components/web3/impl/DefaultWeb3StreamerImpl.java Tue Apr 26 09:46:03 2005 @@ -1,12 +1,12 @@ /* * Copyright 1999-2004 The Apache Software Foundation. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,40 +32,40 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Michael Gerzabek</a> * @since 2.1 - * @version CVS $Id: DefaultWeb3StreamerImpl.java,v 1.7 2004/03/05 13:02:25 bdelacretaz Exp $ + * @version CVS $Id$ */ public class DefaultWeb3StreamerImpl implements Web3Streamer, Poolable { - public void stream(JCO.Function function, - ContentHandler contentHandler) throws SAXException { + public void stream(JCO.Function function, + ContentHandler contentHandler) + throws SAXException { - AttributesImpl attributes = new AttributesImpl(); - attributes.clear(); - attributes.addAttribute( Web3.URI, Web3.INCLUDE_NAME_ATTR, + AttributesImpl attributes = new AttributesImpl(); + attributes.addAttribute( Web3.URI, Web3.INCLUDE_NAME_ATTR, Web3.INCLUDE_NAME_ATTR, "CDATA", function.getName().toUpperCase() ); - contentHandler.startElement( Web3.URI, Web3.INCLUDE_ELEM, + contentHandler.startElement( Web3.URI, Web3.INCLUDE_ELEM, Web3.INCLUDE_ELEM, attributes ); attributes.clear(); - contentHandler.startElement( Web3.URI, Web3.IMPORT_ELEM, + contentHandler.startElement( Web3.URI, Web3.IMPORT_ELEM, Web3.IMPORT_ELEM, attributes ); streamParameterList( function.getImportParameterList(), contentHandler ); contentHandler.endElement( Web3.URI, Web3.IMPORT_ELEM, Web3.IMPORT_ELEM ); attributes.clear(); - contentHandler.startElement( Web3.URI, Web3.EXPORT_ELEM, + contentHandler.startElement( Web3.URI, Web3.EXPORT_ELEM, Web3.EXPORT_ELEM, attributes ); streamParameterList( function.getExportParameterList(), contentHandler ); contentHandler.endElement( Web3.URI, Web3.EXPORT_ELEM, Web3.EXPORT_ELEM ); - + JCO.ParameterList tablesParameterList = function.getTableParameterList(); attributes.clear(); - contentHandler.startElement( Web3.URI, Web3.TABLES_ELEM, + contentHandler.startElement( Web3.URI, Web3.TABLES_ELEM, Web3.TABLES_ELEM, attributes ); if (null != tablesParameterList) { for (int i = 0; i < tablesParameterList.getFieldCount(); i++) { attributes.clear(); - attributes.addAttribute( Web3.URI, Web3.TABLE_NAME_ATTR, - Web3.TABLE_NAME_ATTR, "CDATA", + attributes.addAttribute( Web3.URI, Web3.TABLE_NAME_ATTR, + Web3.TABLE_NAME_ATTR, "CDATA", tablesParameterList.getName(i).toUpperCase() ); contentHandler.startElement( Web3.URI, Web3.TABLE_ELEM, Web3.TABLE_ELEM, attributes ); @@ -74,87 +74,86 @@ for (int j = 0; j < sapTable.getNumRows(); j++) { sapTable.setRow(j); attributes.clear(); - attributes.addAttribute(Web3.URI, Web3.ROW_ID_ATTR, + attributes.addAttribute(Web3.URI, Web3.ROW_ID_ATTR, Web3.ROW_ID_ATTR, "CDATA", "" + (j + 1)); - contentHandler.startElement(Web3.URI, Web3.ROW_ELEM, + contentHandler.startElement(Web3.URI, Web3.ROW_ELEM, Web3.ROW_ELEM, attributes); for (int k = 0; k < sapTable.getFieldCount(); k++) { attributes.clear(); - attributes.addAttribute(Web3.URI, - Web3.FIELD_NAME_ATTR, Web3.FIELD_NAME_ATTR, + attributes.addAttribute(Web3.URI, + Web3.FIELD_NAME_ATTR, Web3.FIELD_NAME_ATTR, "CDATA", sapTable.getName(k).toUpperCase()); - contentHandler.startElement(Web3.URI, + contentHandler.startElement(Web3.URI, Web3.FIELD_ELEM, Web3.FIELD_ELEM, attributes); - String theValue = ( sapTable.getString(k) == null) + String theValue = ( sapTable.getString(k) == null) ? "" : sapTable.getString(k).trim(); - contentHandler.characters(theValue.toCharArray(), 0, + contentHandler.characters(theValue.toCharArray(), 0, theValue.length()); - contentHandler.endElement(Web3.URI, Web3.FIELD_ELEM, + contentHandler.endElement(Web3.URI, Web3.FIELD_ELEM, Web3.FIELD_ELEM); } - contentHandler.endElement(Web3.URI, Web3.ROW_ELEM, + contentHandler.endElement(Web3.URI, Web3.ROW_ELEM, Web3.ROW_ELEM); } - contentHandler.endElement(Web3.URI, Web3.TABLE_ELEM, + contentHandler.endElement(Web3.URI, Web3.TABLE_ELEM, Web3.TABLE_ELEM); } - } + } } contentHandler.endElement(Web3.URI, Web3.TABLES_ELEM, Web3.TABLES_ELEM); - contentHandler.endElement( Web3.URI, Web3.INCLUDE_ELEM, + contentHandler.endElement( Web3.URI, Web3.INCLUDE_ELEM, Web3.INCLUDE_ELEM ); } - + protected void streamParameterList(JCO.ParameterList pList, - ContentHandler contentHandler) throws SAXException { - + ContentHandler contentHandler) + throws SAXException { + AttributesImpl attributes = new AttributesImpl(); - attributes.clear(); if (pList != null) { for (int i = 0; i < pList.getFieldCount(); i++) { + attributes.clear(); + JCO.Field theField = pList.getField(i); if (theField.isStructure()) { - JCO.Structure sapStructure = + JCO.Structure sapStructure = pList.getStructure(pList.getName(i)); - attributes.clear(); - attributes.addAttribute(Web3.URI, Web3.STRUCTURE_NAME_ATTR, - Web3.STRUCTURE_NAME_ATTR, "CDATA", + attributes.addAttribute(Web3.URI, Web3.STRUCTURE_NAME_ATTR, + Web3.STRUCTURE_NAME_ATTR, "CDATA", pList.getName(i).toUpperCase()); - contentHandler.startElement(Web3.URI, Web3.STRUCTURE_ELEM, - Web3.STRUCTURE_ELEM, attributes); + contentHandler.startElement(Web3.URI, Web3.STRUCTURE_ELEM, + Web3.STRUCTURE_ELEM, attributes); for (int j = 0; j < sapStructure.getFieldCount(); j++) { attributes.clear(); - attributes.addAttribute(Web3.URI, Web3.FIELD_NAME_ATTR, - Web3.FIELD_NAME_ATTR, "CDATA", + attributes.addAttribute(Web3.URI, Web3.FIELD_NAME_ATTR, + Web3.FIELD_NAME_ATTR, "CDATA", sapStructure.getName(j).toUpperCase()); - contentHandler.startElement(Web3.URI, Web3.FIELD_ELEM, + contentHandler.startElement(Web3.URI, Web3.FIELD_ELEM, Web3.FIELD_ELEM, attributes); - String theValue = (sapStructure.getString(j) == null) + String theValue = (sapStructure.getString(j) == null) ? "" : sapStructure.getString(j).trim(); - contentHandler.characters(theValue.toCharArray(), 0, + contentHandler.characters(theValue.toCharArray(), 0, theValue.length()); - contentHandler.endElement(Web3.URI, Web3.FIELD_ELEM, + contentHandler.endElement(Web3.URI, Web3.FIELD_ELEM, Web3.FIELD_ELEM); } - contentHandler.endElement(Web3.URI, Web3.STRUCTURE_ELEM, + contentHandler.endElement(Web3.URI, Web3.STRUCTURE_ELEM, Web3.STRUCTURE_ELEM); - } - else { - attributes.clear(); - attributes.addAttribute(Web3.URI, Web3.FIELD_NAME_ATTR, - Web3.FIELD_NAME_ATTR, "CDATA", + } else { + attributes.addAttribute(Web3.URI, Web3.FIELD_NAME_ATTR, + Web3.FIELD_NAME_ATTR, "CDATA", pList.getName(i).toUpperCase()); - contentHandler.startElement(Web3.URI, Web3.FIELD_ELEM, + contentHandler.startElement(Web3.URI, Web3.FIELD_ELEM, Web3.FIELD_ELEM, attributes); String theValue = (pList.getString(i) == null) ? "" : pList.getString(i).trim(); - contentHandler.characters(theValue.toCharArray(), 0, + contentHandler.characters(theValue.toCharArray(), 0, theValue.length()); - contentHandler.endElement(Web3.URI, Web3.FIELD_ELEM, + contentHandler.endElement(Web3.URI, Web3.FIELD_ELEM, Web3.FIELD_ELEM); } } - } + } } }