Examples of Outputter


Examples of com.icl.saxon.output.Outputter

   * <p>Optional encoding attribute can specify encoding of resource.
   * If not specified default system encoding is used.</p>
   *
   */
  public void process( Context context ) throws TransformerException {
    Outputter out = context.getOutputter();

    String hrefAtt = getAttribute("href");
    Expression hrefExpr = makeAttributeValueTemplate(hrefAtt);
    String href = hrefExpr.evaluateAsString(context);

    String encodingAtt = getAttribute("encoding");
    Expression encodingExpr = makeAttributeValueTemplate(encodingAtt);
    String encoding = encodingExpr.evaluateAsString(context);

    String baseURI = context.getContextNodeInfo().getBaseURI();

    URIResolver resolver = context.getController().getURIResolver();

    if (resolver != null) {
      Source source = resolver.resolve(href, baseURI);
      href = source.getSystemId();
    }

    URL baseURL = null;
    URL fileURL = null;

    try {
      baseURL = new URL(baseURI);
    } catch (MalformedURLException e0) {
      // what the!?
      baseURL = null;
    }

    try {
      try {
        fileURL = new URL(baseURL, href);
      } catch (MalformedURLException e1) {
        try {
          fileURL = new URL(baseURL, "file:" + href);
        } catch (MalformedURLException e2) {
          System.out.println("Cannot open " + href);
          return;
        }
      }

      InputStreamReader isr = null;
      if (encoding.equals("") == true)
        isr = new InputStreamReader(fileURL.openStream());
      else
        isr = new InputStreamReader(fileURL.openStream(), encoding);

      BufferedReader is = new BufferedReader(isr);

      final int BUFFER_SIZE = 4096;
      char chars[] = new char[BUFFER_SIZE];
      char nchars[] = new char[BUFFER_SIZE];
      int len = 0;
      int i = 0;
      int carry = -1;

      while ((len = is.read(chars)) > 0) {
        // various new lines are normalized to LF to prevent blank lines
  // between lines

        int nlen = 0;
        for (i=0; i<len; i++) {
          // is current char CR?
          if (chars[i] == '\r') {
            if (i < (len - 1)) {
              // skip it if next char is LF
              if (chars[i+1] == '\n') continue;
              // single CR -> LF to normalize MAC line endings
              nchars[nlen] = '\n';
              nlen++;
              continue;
            } else {
              // if CR is last char of buffer we must look ahead
              carry = is.read();
              nchars[nlen] = '\n';
              nlen++;
              if (carry == '\n') {
                carry = -1;
              }
              break;
            }
          }
          nchars[nlen] = chars[i];
          nlen++;
        }
        out.writeContent(nchars, 0, nlen);
        // handle look aheaded character
        if (carry != -1) out.writeContent(String.valueOf((char)carry));
        carry = -1;
      }
      is.close();
    } catch (Exception e) {
      System.out.println("Cannot read " + href);
View Full Code Here

Examples of com.icl.saxon.output.Outputter

   * <p>Optional encoding attribute can specify encoding of resource.
   * If not specified default system encoding is used.</p>
   *
   */
  public void process( Context context ) throws TransformerException {
    Outputter out = context.getOutputter();

    String hrefAtt = getAttribute("href");
    Expression hrefExpr = makeAttributeValueTemplate(hrefAtt);
    String href = hrefExpr.evaluateAsString(context);

    String encodingAtt = getAttribute("encoding");
    Expression encodingExpr = makeAttributeValueTemplate(encodingAtt);
    String encoding = encodingExpr.evaluateAsString(context);

    String baseURI = context.getContextNodeInfo().getBaseURI();

    URIResolver resolver = context.getController().getURIResolver();

    if (resolver != null) {
      Source source = resolver.resolve(href, baseURI);
      href = source.getSystemId();
    }

    URL baseURL = null;
    URL fileURL = null;

    try {
      baseURL = new URL(baseURI);
    } catch (MalformedURLException e0) {
      // what the!?
      baseURL = null;
    }

    try {
      try {
        fileURL = new URL(baseURL, href);
      } catch (MalformedURLException e1) {
        try {
          fileURL = new URL(baseURL, "file:" + href);
        } catch (MalformedURLException e2) {
          System.out.println("Cannot open " + href);
          return;
        }
      }

      InputStreamReader isr = null;
      if (encoding.equals("") == true)
        isr = new InputStreamReader(fileURL.openStream());
      else
        isr = new InputStreamReader(fileURL.openStream(), encoding);

      BufferedReader is = new BufferedReader(isr);

      final int BUFFER_SIZE = 4096;
      char chars[] = new char[BUFFER_SIZE];
      char nchars[] = new char[BUFFER_SIZE];
      int len = 0;
      int i = 0;
      int carry = -1;

      while ((len = is.read(chars)) > 0) {
        // various new lines are normalized to LF to prevent blank lines
  // between lines

        int nlen = 0;
        for (i=0; i<len; i++) {
          // is current char CR?
          if (chars[i] == '\r') {
            if (i < (len - 1)) {
              // skip it if next char is LF
              if (chars[i+1] == '\n') continue;
              // single CR -> LF to normalize MAC line endings
              nchars[nlen] = '\n';
              nlen++;
              continue;
            } else {
              // if CR is last char of buffer we must look ahead
              carry = is.read();
              nchars[nlen] = '\n';
              nlen++;
              if (carry == '\n') {
                carry = -1;
              }
              break;
            }
          }
          nchars[nlen] = chars[i];
          nlen++;
        }
        out.writeContent(nchars, 0, nlen);
        // handle look aheaded character
        if (carry != -1) out.writeContent(String.valueOf((char)carry));
        carry = -1;
      }
      is.close();
    } catch (Exception e) {
      System.out.println("Cannot read " + href);
View Full Code Here

Examples of com.uic.ase.proj.xbn.output.Outputter

    <P>Create a DSConfig.</P>

    <P>Equal to <CODE><A HREF="~JD~dsc(i,b,b,optr)~EJD~">DSConfig</A>(i_lvlsMaxDepth, b_ignoreDirs, b_filesFirst, (new <A HREF="~JD~optr#optr()~EJD~">Outputter</A>()))</CODE></P>
   **/
   public DSConfig(int i_lvlsMaxDepth, boolean b_ignoreDirs, boolean b_filesFirst)  {
     this(i_lvlsMaxDepth, b_ignoreDirs, b_filesFirst, (new Outputter()));
   }
View Full Code Here

Examples of com.uic.ase.proj.xbn.output.Outputter

    <P>Equal to <CODE><A HREF="~JD~dsc(i,b,b,ff,optr)~EJD~">DSConfig</A>(i_lvlsMaxDepth, b_ignoreDirs, b_filesFirst, file_filter, (new <A HREF="~JD~optr#optr()~EJD~">Outputter</A>()))</CODE></P>

    <P>Note:  To set file_filter to null, use either <CODE>(FileFilter)null</CODE> or use <A HREF="~JD~dsc(i,b,b)~EJD~">this constructor</A> instead.</P>
   **/
   public DSConfig(int i_lvlsMaxDepth, boolean b_ignoreDirs, boolean b_filesFirst, FileFilter file_filter)  {
     this(i_lvlsMaxDepth, b_ignoreDirs, b_filesFirst, file_filter, (new Outputter()));
   }
View Full Code Here

Examples of com.uic.ase.proj.xbn.output.Outputter

    <P>Create a DirFile.</P>

    <P>Equal to <A HREF="~JD~df(s,optr)~EJD~">DirFile</A>(s_basePath, (new <A HREF="~JD~optr#optr()~EJD~">Outputter</A>()))</P>
   **/
  public DirFile(String s_basePath)  {
    this(s_basePath, (new Outputter()));
  }
View Full Code Here

Examples of com.uic.ase.proj.xbn.output.Outputter

    <P>Create a DirFile.</P>

    <P>Equal to <A HREF="~JD~df(s,i,optr)~EJD~">DirFile</A>(s_basePath, i_levelsToAnalyze, (new <A HREF="~JD~optr#optr()~EJD~">Outputter</A>()))</P>
   **/
  public DirFile(String s_basePath, int i_levelsToAnalyze)  {
    this(s_basePath, i_levelsToAnalyze, (new Outputter()));
  }
View Full Code Here

Examples of com.uic.ase.proj.xbn.output.Outputter

    <P>Create a DirFile.</P>

    <P>Equal to <A HREF="~JD~df(s,i,ff,optr)~EJD~">DirFile</A>(s_basePath, i_levelsToAnalyze, file_filter, (new <A HREF="~JD~optr#optr()~EJD~">Outputter</A>())))</P>
   **/
  public DirFile(String s_basePath, int i_levelsToAnalyze, FileFilter file_filter)  {
    this(s_basePath, i_levelsToAnalyze, file_filter, (new Outputter()));
  }
View Full Code Here

Examples of com.uic.ase.proj.xbn.output.Outputter

    <P>Create a DBConnDirect.</P>

    <P>Equal to <CODE><A HREF="~JD~dbcd(s,optr)~EJD~">DBConnDirect</A>(s_verificationSelect, (new <A HREF="~JD~optr#optr()~EJD~">Outputter</A>()))</CODE></P>
   **/
  public DBConnDirect(String s_verificationSelect)  {
    this(s_verificationSelect, (new Outputter()));
  }
View Full Code Here

Examples of com.uic.ase.proj.xbn.output.Outputter

    <P>Create a TParseConfig.</P>

    <P>Equal to <CODE><A HREF="~JD~tpc(gc,b,optr)~EJD~">TParseConfig</A>(gap_config, b_ignoreSurrTxt, (new <A HREF="~JD~optr#optr()~EJD~">Outputter</A>()))</CODE></P>
   **/
  public TParseConfig(GapConfig gap_config, boolean b_ignoreSurrTxt)  {
    this(gap_config, b_ignoreSurrTxt, (new Outputter()));
  }
View Full Code Here

Examples of com.uic.ase.proj.xbn.output.Outputter

    <P>Create a TParseConfig.</P>

    <P>Equal to <CODE><A HREF="~JD~tpc(gc,b,usci,optr)~EJD~">TParseConfig</A>(gap_config, b_ignoreSurrTxt, euscu_ignore, (new <A HREF="~JD~optr#optr()~EJD~">Outputter</A>()))</CODE></P>
   **/
  public TParseConfig(GapConfig gap_config, boolean b_ignoreSurrTxt, USCIgnore euscu_ignore)  {
    this(gap_config, b_ignoreSurrTxt, euscu_ignore, (new Outputter()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.