Getting the content of InputSource!! Need Help!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madumm
    New Member
    • Jan 2007
    • 18

    Getting the content of InputSource!! Need Help!!

    Hi all;

    My problem is as follows::

    // Class_1 code
    ------------------------------------------------------------------------
    private char[] fo;
    CharArrayWriter fos = new CharArrayWriter ();
    fo =fos.toCharArra y();
    InputSource foSource = new InputSource(new CharArrayReader (fo));

    //This foSource is passed to a method in Class_2 (Driver);
    driver.render(x mlReader, foSource);


    Class_2 (Driver)code;
    ---------------------------------------------------------------------------------------
    public synchronized void render(XMLReade r parser, InputSource source)
    throws FOPException {

    ---------
    ---------
    ---------

    }


    Qn) In render method in Driver class; i want to convert that InputSource "source" back into a char array.
    Is it possible to do like that?
    Because in Class_1 "fos" content is like this

    <fo:root ............... ............... ............... ............... ............... .............>
    <fo:external-graphic left="29mm" top="355mm" width="538mm" height="132mm" src="file:./report_designer _graphics/FNDBAS/FND_SESSION_REP/Error.JPG"/>
    </fo:root>

    Under render method i want to get this content back by using "source" InputSource by way of a char array of by any other way. Is it possible?

    Ur help will be greatly appreciated
    Thank
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by madumm
    Hi all;

    My problem is as follows::

    // Class_1 code
    ------------------------------------------------------------------------
    private char[] fo;
    CharArrayWriter fos = new CharArrayWriter ();
    fo =fos.toCharArra y();
    InputSource foSource = new InputSource(new CharArrayReader (fo));

    //This foSource is passed to a method in Class_2 (Driver);
    driver.render(x mlReader, foSource);


    Class_2 (Driver)code;
    ---------------------------------------------------------------------------------------
    public synchronized void render(XMLReade r parser, InputSource source)
    throws FOPException {

    ---------
    ---------
    ---------

    }


    Qn) In render method in Driver class; i want to convert that InputSource "source" back into a char array.
    Is it possible to do like that?
    Because in Class_1 "fos" content is like this

    <fo:root ............... ............... ............... ............... ............... .............>
    <fo:external-graphic left="29mm" top="355mm" width="538mm" height="132mm" src="file:./report_designer _graphics/FNDBAS/FND_SESSION_REP/Error.JPG"/>
    </fo:root>

    Under render method i want to get this content back by using "source" InputSource by way of a char array of by any other way. Is it possible?

    Ur help will be greatly appreciated
    Thank
    What methods are there in the InputSource class?

    Comment

    • madumm
      New Member
      • Jan 2007
      • 18

      #3
      The method in InputSource are:

      public InputSource (String systemId)
      {
      setSystemId(sys temId);
      }

      public InputSource (InputStream byteStream)
      {
      setByteStream(b yteStream);
      }

      public InputSource (Reader characterStream )
      {
      setCharacterStr eam(characterSt ream);
      }

      public void setPublicId (String publicId)
      {
      this.publicId = publicId;
      }

      public String getPublicId ()
      {
      return publicId;
      }

      public void setSystemId (String systemId)
      {
      this.systemId = systemId;
      }

      public String getSystemId ()
      {
      return systemId;
      }

      public void setByteStream (InputStream byteStream)
      {
      this.byteStream = byteStream;
      }

      public InputStream getByteStream ()
      {
      return byteStream;
      }

      public void setEncoding (String encoding)
      {
      this.encoding = encoding;
      }

      public String getEncoding ()
      {
      return encoding;
      }

      public void setCharacterStr eam (Reader characterStream )
      {
      this.characterS tream = characterStream ;
      }

      public Reader getCharacterStr eam ()
      {
      return characterStream ;
      }

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by madumm
        The method in InputSource are:

        public InputSource (String systemId)
        {
        setSystemId(sys temId);
        }

        public InputSource (InputStream byteStream)
        {
        setByteStream(b yteStream);
        }

        public InputSource (Reader characterStream )
        {
        setCharacterStr eam(characterSt ream);
        }

        public void setPublicId (String publicId)
        {
        this.publicId = publicId;
        }

        public String getPublicId ()
        {
        return publicId;
        }

        public void setSystemId (String systemId)
        {
        this.systemId = systemId;
        }

        public String getSystemId ()
        {
        return systemId;
        }

        public void setByteStream (InputStream byteStream)
        {
        this.byteStream = byteStream;
        }

        public InputStream getByteStream ()
        {
        return byteStream;
        }

        public void setEncoding (String encoding)
        {
        this.encoding = encoding;
        }

        public String getEncoding ()
        {
        return encoding;
        }

        public void setCharacterStr eam (Reader characterStream )
        {
        this.characterS tream = characterStream ;
        }

        public Reader getCharacterStr eam ()
        {
        return characterStream ;
        }
        The getCharacterStr eam method seems your best option to get the array from

        Comment

        • madumm
          New Member
          • Jan 2007
          • 18

          #5
          But i tried that too; i encounterd this problem while doing

          if (source.getChar acterStream( ) != null) {
          br = new BufferedReader( source.getChara cterStream( ));
          br.read(buffer_ 2, start_2, length_2);

          This is giving a:::

          java.io.IOExcep tion: Stream closed

          at java.io.CharArr ayReader.ensure Open(CharArrayR eader.java:65)

          at java.io.CharArr ayReader.read(C harArrayReader. java:95)

          at java.io.Buffere dReader.read1(B ufferedReader.j ava:185)

          at java.io.Buffere dReader.read(Bu fferedReader.ja va:261)

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by madumm
            But i tried that too; i encounterd this problem while doing

            if (source.getChar acterStream( ) != null) {
            br = new BufferedReader( source.getChara cterStream( ));
            br.read(buffer_ 2, start_2, length_2);

            This is giving a:::

            java.io.IOExcep tion: Stream closed

            at java.io.CharArr ayReader.ensure Open(CharArrayR eader.java:65)

            at java.io.CharArr ayReader.read(C harArrayReader. java:95)

            at java.io.Buffere dReader.read1(B ufferedReader.j ava:185)

            at java.io.Buffere dReader.read(Bu fferedReader.ja va:261)
            I'm sure the exception is explaining itself well here.

            Comment

            • madumm
              New Member
              • Jan 2007
              • 18

              #7
              Originally posted by r035198x
              The getCharacterStr eam method seems your best option to get the array from

              I didn't get what u r saying

              Comment

              Working...