Package java.io

Examples of java.io.StringBufferInputStream


      if (xml.substring(xml.length() - 3, xml.length()).equals("xml"))
      {
        returnDocument = builder.parse(new File(filePath + xml));
      } else
      {
        InputStream in = new BufferedInputStream(new StringBufferInputStream(xml));
        returnDocument = builder.parse(in);
      }
    } catch (IOException e)
    {
      logger.error("[getDocumentFromString] Exception thrown.", e);
View Full Code Here


          flvo.setOwner(indvID);

          //flvo.setAuthor(indvID);
          flvo.setPhysical(CvFileVO.FP_PHYSICAL);

          StringBufferInputStream stringInputStream = new StringBufferInputStream(importInputStream.toString());
          int fileId = cvf.addFile(indvID, homeFld.getFolderId(), flvo, stringInputStream, this.dataSource);
          messageList.put("fileID",fileId + "");
        } catch (Exception e) {
          logger.error("[Exception] ListEJB.getImportList: ", e);
        }
View Full Code Here

   */

  public ByteArrayOutputStream transformHTML(String sHTML)
    throws IOException,FOPException,TransformerException,TransformerConfigurationException {
    ByteArrayOutputStream oXml = new ByteArrayOutputStream();
    StringBufferInputStream oHtm = new StringBufferInputStream(sHTML);
    Tidy oTdy = new Tidy();
    oTdy.setXmlOut(true);
    oTdy.setTidyMark(false);
    oTdy.setNumEntities(true);
  oTdy.parseDOM(oHtm, oXml);
View Full Code Here

        // This method parses an XML document into a ShoppingBasket instace

        // local variables
        XMLReader parser;
        Parser sax1Parser;
        StringBufferInputStream oStrBuff;
        InputSource ioSrc;

        if (DebugFile.trace) {
          DebugFile.writeln ("Begin ShoppingBasket.parse(String)");
          DebugFile.incIdent();
        }

        try {
          if (DebugFile.trace) DebugFile.writeln ("XMLReaderFactory.createXMLReader(" + DEFAULT_PARSER_NAME + ")");

          parser = XMLReaderFactory.createXMLReader(DEFAULT_PARSER_NAME);
        }
        catch (Exception e) {
            if (DebugFile.trace) DebugFile.writeln ("ParserFactory.makeParser(" + DEFAULT_PARSER_NAME + ")");

            sax1Parser = ParserFactory.makeParser(DEFAULT_PARSER_NAME);

            parser = new ParserAdapter(sax1Parser);
            if (DebugFile.trace)
              DebugFile.writeln("warning: Features and properties not supported on SAX1 parsers.");
        }
        try {
          parser.setFeature(NAMESPACES_FEATURE_ID, DEFAULT_NAMESPACES);
          parser.setFeature(VALIDATION_FEATURE_ID, DEFAULT_VALIDATION);
        }
        catch (SAXException e) {
        }

      // parse file
      parser.setContentHandler(this);
      parser.setErrorHandler(this);

      oStrBuff = new StringBufferInputStream(sXMLData);
      ioSrc = new InputSource(oStrBuff);
      parser.parse(ioSrc);
      oStrBuff.close();

      if (DebugFile.trace) {
        DebugFile.decIdent();
        DebugFile.writeln ("End ShoppingBasket.parse()");
      }
View Full Code Here

        XMLReader parser;
        Parser sax1Parser;
        File oFile;
        FileReader oFileRead;
        BufferedReader oBuff;
        StringBufferInputStream oStrBuff;
        InputSource ioSrc;
        FileInputStream oStream;
        String sXMLSource;
        String sParam;
        Enumeration oEnum;
        Pattern oPattern;
        PatternMatcher oMatcher = new Perl5Matcher();
        PatternCompiler oCompiler = new Perl5Compiler();
        byte byBuffer[];

        if (DebugFile.trace) {
          DebugFile.writeln ("Begin DataStruct.parse(" + sXMLFile + ")");
          DebugFile.incIdent();
        }

        try {
          if (DebugFile.trace) DebugFile.writeln ("XMLReaderFactory.createXMLReader(" + DEFAULT_PARSER_NAME + ")");

          parser = XMLReaderFactory.createXMLReader(DEFAULT_PARSER_NAME);
        }
        catch (Exception e) {
            if (DebugFile.trace) DebugFile.writeln ("ParserFactory.makeParser(" + DEFAULT_PARSER_NAME + ")");

            sax1Parser = ParserFactory.makeParser(DEFAULT_PARSER_NAME);

            parser = new ParserAdapter(sax1Parser);
            if (DebugFile.trace)
              DebugFile.writeln("warning: Features and properties not supported on SAX1 parsers.");
        }
        try {
          parser.setFeature(NAMESPACES_FEATURE_ID, DEFAULT_NAMESPACES);
          parser.setFeature(VALIDATION_FEATURE_ID, DEFAULT_VALIDATION);
        }
        catch (SAXException e) {
        }

      // parse file
      parser.setContentHandler(this);
      parser.setErrorHandler(this);

      oEnum = oProps.keys();
      if (sXMLFile.startsWith("<?xml")) {
        // replace input parameters
        while (oEnum.hasMoreElements()) {
          sParam = (String) oEnum.nextElement();
          try {
            oPattern = oCompiler.compile("{#" + sParam + "}");
          } catch (MalformedPatternException e) { oPattern=null; }

          sXMLFile = Util.substitute(oMatcher, oPattern,
                                 new Perl5Substitution(oProps.getProperty(sParam), Perl5Substitution.INTERPOLATE_ALL),
                                 sXMLFile, Util.SUBSTITUTE_ALL);
        } // wend()

        oStrBuff = new StringBufferInputStream(sXMLFile);
        ioSrc = new InputSource(oStrBuff);
        parser.parse(ioSrc);
        oStrBuff.close();
      }
      else {
        if (oProps.isEmpty()) {
          oFileRead = new FileReader(sXMLFile);
          oBuff = new BufferedReader(oFileRead, 32767);
          ioSrc = new InputSource(oBuff);
          parser.parse(ioSrc);
          oBuff.close();
          oFileRead.close();
        }
        else {
          oFile = new File(sXMLFile);
          byBuffer = new byte[new Long(oFile.length()).intValue()];

          oStream = new FileInputStream(oFile);
          oStream.read(byBuffer);
          sXMLSource = new String(byBuffer);
          oStream.close();

          while (oEnum.hasMoreElements()) {
            sParam = (String) oEnum.nextElement();
            try {
              oPattern = oCompiler.compile("{#" + sParam + "}");
            } catch (MalformedPatternException e) { oPattern=null; }

            sXMLSource = Util.substitute(oMatcher, oPattern,
                                   new Perl5Substitution(oProps.getProperty(sParam), Perl5Substitution.INTERPOLATE_ALL),
                                   sXMLSource, Util.SUBSTITUTE_ALL);
          } // wend()

          oStrBuff = new StringBufferInputStream(sXMLSource);
          ioSrc = new InputSource(oStrBuff);
          parser.parse(ioSrc);
          oStrBuff.close();
        }
      }

      if (DebugFile.trace) {
        DebugFile.decIdent();
View Full Code Here

 
  CalendarResponse oCalRsp = null

    String sResponse = readfilestr(sUrl,"UTF-8");

  StringBufferInputStream oResponse = new StringBufferInputStream(sResponse);

    IBindingFactory bfact = BindingDirectory.getFactory(CalendarResponse.class);
    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();

    oCalRsp = (CalendarResponse) uctx.unmarshalDocument (oResponse, "UTF-8");
View Full Code Here

        byBuffer = null;

        if (DebugFile.trace) DebugFile.writeln (new String(byEnvVars, 0, iEnvLength));

        envVars.load (new StringBufferInputStream(new String(byEnvVars, 0, iEnvLength)));

      }
      else {

        if (DebugFile.trace) DebugFile.writeln ("Runtime.getRuntime()");
View Full Code Here

                if (sClassName.equals("java.io.File"))
                  oStream = new FileInputStream((File) AllValues.get(sCol));
                else if (sClassName.equals("[B"))
                  oStream = new ByteArrayInputStream((byte[]) AllValues.get(sCol));
                else if (sClassName.equals("[C"))
                  oStream = new StringBufferInputStream(new String((char[]) AllValues.get(sCol)));
                else {
                  Class[] aInts = AllValues.get(sCol).getClass().getInterfaces();
                  if (aInts==null) {
                    throw new SQLException ("Invalid object binding for column " + sCol);
                  } else {
                    boolean bSerializable = false;
                    for (int i=0; i<aInts.length &!bSerializable; i++)
                      bSerializable |= aInts[i].getName().equals("java.io.Serializable");
                    if (bSerializable) {
                      ByteArrayOutputStream oBOut = new ByteArrayOutputStream();
                      ObjectOutputStream oOOut = new ObjectOutputStream(oBOut);
                      oOOut.writeObject(AllValues.get(sCol));
                      oOOut.close();
                      ByteArrayInputStream oBin = new ByteArrayInputStream(oBOut.toByteArray());
                      oStream = new ObjectInputStream(oBin);                   
                    } else {
                      throw new SQLException ("Invalid object binding for column " + sCol);                     
                    }
                  } // fi
                }
                oStreams.addLast(oStream);
                oStmt.setBinaryStream(c++, oStream, ((Long)BinaryLengths.get(sCol)).intValue());
              }
              else
                oStmt.setObject (c++, null, oCol.getSqlType());
            }
            else
             oStmt.setObject (c++, null, oCol.getSqlType());
          }
          else
            oConn.bindParameter (oStmt, c++, AllValues.get(sCol), oCol.getSqlType());
          } // fi (!oPrimaryKeys.contains(sCol))
        } // wend

      oColIterator = oPrimaryKeys.listIterator();
      while (oColIterator.hasNext()) {
        sCol = (String) oColIterator.next();
        oCol = getColumnByName(sCol);

        if (DebugFile.trace) DebugFile.writeln("PreparedStatement.setObject (" + String.valueOf(c) + "," + AllValues.get(sCol) + "," + oCol.getSqlTypeName() + ")");

        oConn.bindParameter (oStmt, c, AllValues.get(sCol), oCol.getSqlType());
        c++;
      } // wend

      if (DebugFile.trace) DebugFile.writeln("PreparedStatement.executeUpdate()");

      iAffected = oStmt.executeUpdate();

      if (DebugFile.trace) DebugFile.writeln(String.valueOf(iAffected) " affected rows");

      oStmt.close();

      oColIterator = oStreams.listIterator();

      while (oColIterator.hasNext())
        ((InputStream) oColIterator.next()).close();

      oStreams.clear();

    }
    else
      iAffected = 0;

    if (0==iAffected)
        {
        bNewRow = true;

        if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(" + sInsert + ")");

        oStmt = oConn.prepareStatement(sInsert);

        c = 1;
        oColIterator = oColumns.listIterator();

        while (oColIterator.hasNext()) {

          oCol  = (DBColumn)oColIterator.next();
          sCol = oCol.getName();

          if (DebugFile.trace) {
            if (null!=AllValues.get(sCol))
              DebugFile.writeln("Binding " + sCol + "=" + AllValues.get(sCol).toString());
            else
              DebugFile.writeln("Binding " + sCol + "=NULL");
          }

          if (oCol.getSqlType()==java.sql.Types.LONGVARCHAR || oCol.getSqlType()==java.sql.Types.CLOB || oCol.getSqlType()==java.sql.Types.LONGVARBINARY || oCol.getSqlType()==java.sql.Types.BLOB) {
            if (BinaryLengths.containsKey(sCol)) {
              if ( ( (Long) BinaryLengths.get(sCol)).intValue() > 0) {
                sClassName = AllValues.get(sCol).getClass().getName();
                if (sClassName.equals("java.io.File"))
                  oStream = new FileInputStream((File) AllValues.get(sCol));
                else if (sClassName.equals("[B"))
                  oStream = new ByteArrayInputStream((byte[]) AllValues.get(sCol));
                else if (sClassName.equals("[C"))
                  oStream = new StringBufferInputStream(new String((char[]) AllValues.get(sCol)));
                else {
                  Class[] aInts = AllValues.get(sCol).getClass().getInterfaces();
                  if (aInts==null) {
                    throw new SQLException ("Invalid object binding for column " + sCol);
                  } else {
View Full Code Here

    File oFile;                      // Document Template File
    FileReader oFileRead;            // Document Template Reader
    String sPathHTML;                // Full Path to Document Template File
    char cBuffer[];                  // Internal Buffer for Document Template File Data
    StringBufferInputStream oInStrm; // Document Template File Data after replacing images src http: with cid:
    String oReplaced;                // Document Template File Data after FastStreamReplacer processing
    final String Yes = "1";

    final String sSep = System.getProperty("file.separator"); // Alias for file.separator

    if (DebugFile.trace) {
      DebugFile.writeln("Begin EMailSender.process([Job:" + getStringNull(DB.gu_job, "") + ", Atom:" + String.valueOf(oAtm.getInt(DB.pg_atom)) + "])");
      DebugFile.incIdent();
      DebugFile.writeln("document has "+(bHasReplacements ? "" : " no ")+"replacements");
    }

    if (bHasReplacements) { // Initially the document is assumed to have tags to replace

      // *************************************************
      // Compose the full path to document template file

      // First get the storage base path from hipergate.cnf
      sPathHTML = getParameter("workareasput");
      if (null==sPathHTML) sPathHTML = getProperty("workareasput");
      if (!sPathHTML.endsWith(sSep)) sPathHTML += sSep;

        // Concatenate PageSet workarea guid and subpath to Mailwire application directory
      sPathHTML += getParameter("gu_workarea") + sSep + "apps" + sSep + "Mailwire" + sSep + "html" + sSep + getParameter("gu_pageset") + sSep;

      // Concatenate HTML Page Name
      sPathHTML += getParameter("nm_page").replace(' ', '_');

      if (DebugFile.trace) DebugFile.writeln("PathHTML = " + sPathHTML);

      // ***********************************************************************
      // Change <IMG SRC=""> tags for embeding document images into mime message

      if (Yes.equals(getParameter("bo_attachimages"))) {

        if (DebugFile.trace) DebugFile.writeln("bo_attachimages=true");

        // Check first the SoftReference to the tag-replaced in-memory String cache
        oInStrm = null;

        if (null!=oHTMLStr) {
          if (null!=oHTMLStr.get())
            // Get substituted html source as a StringBufferInputStream suitable
            // for FastStreamReplacer replace() method.
            oInStrm = oHTMLStr.get();
        }
        if (null==oInStrm)
          // If SoftReference was not found then
          // call html processor for <IMG> tag substitution
          oInStrm = new StringBufferInputStream(attachFiles(sPathHTML));

        oHTMLStr = new SoftReference<StringBufferInputStream>(oInStrm);

        // Call FastStreamReplacer for {#Section.Field} tags
        oReplaced = oReplacer.replace(oInStrm, oAtm.getItemMap());
View Full Code Here

                log.append("   Match using CharacterArrayCharacterIterator\n");
                if (!tryMatchUsingCI(new CharacterArrayCharacterIterator(toMatch.toCharArray(), 0, toMatch.length())))
                    return;

                log.append("   Match using StreamCharacterIterator\n");
                if (!tryMatchUsingCI(new StreamCharacterIterator(new StringBufferInputStream(toMatch))))
                    return;

                log.append("   Match using ReaderCharacterIterator\n");
                if (!tryMatchUsingCI(new ReaderCharacterIterator(new StringReader(toMatch))))
                    return;
View Full Code Here

TOP

Related Classes of java.io.StringBufferInputStream

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.