Package net.sf.xbus.base.bytearraylist

Examples of net.sf.xbus.base.bytearraylist.ByteArrayList


   *         {@link net.sf.xbus.base.bytearraylist.ByteArrayList}.
   * @exception XException if file can not be read or any I/O error occurs
   */
  protected Object getRequestContent() throws XException
  {
    ByteArrayList retBuffer = new ByteArrayList();

    AS400FileRecordDescription recordDescription = new AS400FileRecordDescription(
        mAS400System, mQSYSObject.getPath());

    try
    {
      // Set record format of the file.
      RecordFormat[] format = recordDescription.retrieveRecordFormat();
      mOriginFile.setRecordFormat(format[0]);

      // Open the file.
      mOriginFile.open(AS400File.READ_WRITE, 0,
          AS400File.COMMIT_LOCK_LEVEL_NONE);

      // Read records
      byte[] inData = null;
      Record record;
      while ((record = mOriginFile.readNext()) != null)
      {
        inData = record.getContents();
        retBuffer.add(inData);
      }
      // close the file since I am done using it
      mOriginFile.close();

    }
View Full Code Here


    return identifierLength;
  }

  private ByteArrayList serializeList(Document doc) throws XException
  {
    ByteArrayList retArrayList = new ByteArrayList();

    ByteArrayConverter conv = ByteArrayConverterFactory
        .getConverter(mEncodingSystem);

    NodeList records = doc.getElementsByTagName(TAG_RECORD);
    Node recordNode;
    NamedNodeMap recordAttributes;
    Attr recordLengthAttr;
    int recordLength;
    byte[] recordArray;

    NodeList fields;
    Node fieldNode;
    NamedNodeMap fieldAttributes;
    Attr fieldLengthAttr;
    int fieldLength;
    Node fieldTextNode;
    String fieldValue;
    byte[] fieldBytes;
    int pos;

    for (int i = 0; i < records.getLength(); i++)
    {
      recordNode = records.item(i);
      recordAttributes = recordNode.getAttributes();
      recordLengthAttr = (Attr) recordAttributes.getNamedItem(TAG_LENGTH);
      recordLength = Integer.parseInt(recordLengthAttr.getNodeValue());
      recordArray = new byte[recordLength];

      pos = 0;

      fields = recordNode.getChildNodes();
      for (int k = 0; k < fields.getLength(); k++)
      {
        fieldNode = fields.item(k);

        if (fieldNode.getNodeType() == Node.ELEMENT_NODE)
        {
          fieldAttributes = fieldNode.getAttributes();
          fieldLengthAttr = (Attr) fieldAttributes
              .getNamedItem(TAG_LENGTH);
          fieldLength = Integer.parseInt(fieldLengthAttr
              .getNodeValue());
          fieldTextNode = fieldNode.getFirstChild();
          fieldValue = fieldTextNode.getNodeValue();
          fieldBytes = conv
              .stringToByteArray(fieldValue, fieldLength);
          for (int m = 0; m < fieldBytes.length; m++)
          {
            recordArray[pos] = fieldBytes[m];
            pos++;
          }
        }
      }
      retArrayList.add(recordArray);
    }
    return retArrayList;
  }
View Full Code Here

  public Object execute(String function, Object callData) throws XException
  {
    RecordFormat format = prepareWriting();

    if (callData == null)
      callData = new ByteArrayList();

    writeData(callData, mOriginFile, format);
    return null;
  }
View Full Code Here

   * @return <code>ByteArrayInputStream</code>
   */
  public Object transform(Object inObject, XBUSSystem source,
      XBUSSystem destination, Message destinationMessage)
  {
    ByteArrayList bal = (ByteArrayList) inObject;

    return new ByteArrayInputStream(bal.toByteArray());
  }
View Full Code Here

      BufferedOutputStream buffOut = new BufferedOutputStream(
          new FileOutputStream(mTempFilename[0], true));

      if (callData == null)
        callData = new ByteArrayList();

      byte[] record = null;
      Iterator it = ((ByteArrayList) callData).iterator();
      if (it.hasNext())
      {
View Full Code Here

      fileLength = new Long(fileLengthLong).intValue();
    }

    if (fileLength < 1)
    {
      return new ByteArrayList();
    }

    /**
     * 2. Read the complete file
     */
 
View Full Code Here

    else
    {
      try
      // for casting to XException
      {
        ByteArrayList bal = (ByteArrayList) obj;
        if (bal.length() == 0)
          setRequestDocument(null, source);
        else
          setRequestDocument(parseRecordsFromByteArrayList(bal,
              source), source);
      } // try
View Full Code Here

    else
    {
      try
      // for casting to XException
      {
        ByteArrayList bal = (ByteArrayList) obj;
        if (bal.length() == 0)
          setRequestDocument(null, destination);
        else
          setResponseDocument(parseRecordsFromByteArrayList(bal,
              destination), destination);
      } // try
View Full Code Here

   *         <code>null</code> for an empty <code>doc</code>
   */
  private ByteArrayList serializeRecordsToByteArrayList(Document doc,
      XBUSSystem system) throws XException
  {
    ByteArrayList records = null;
    try
    {
      records = (ByteArrayList) serializeRecords(doc, system,
          Constants.IFCONTENTCLASS_BYTEARRAYLIST);
    } // try
View Full Code Here

    {
      result = "";
    }
    else if (interfaceContentClass == Constants.IFCONTENTCLASS_BYTEARRAYLIST)
    {
      result = new ByteArrayList();
    }
    else
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL,
View Full Code Here

TOP

Related Classes of net.sf.xbus.base.bytearraylist.ByteArrayList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.