Examples of HeaderPrintWriter


Examples of org.apache.derby.iapi.services.stream.HeaderPrintWriter

    return new BasicHeaderPrintWriter(System.err, header, false, "System.err");
  }

  private HeaderPrintWriter useDefaultStream(PrintWriterGetHeader header, Throwable t) {

    HeaderPrintWriter hpw = useDefaultStream(header);

        while (t != null) {
            Throwable causedBy = t.getCause();
            String causedByStr =
                MessageService.getTextMessage(MessageId.CAUSED_BY);
            hpw.printlnWithHeader(
                t.toString() + (causedBy != null ? " " + causedByStr : ""));
            t = causedBy;
        }

    return hpw;
View Full Code Here

Examples of org.apache.derby.iapi.services.stream.HeaderPrintWriter

    File dir = env instanceof File ? (File) env : null;

        final File classFile = new File(dir, filename);

    // find the error stream
    HeaderPrintWriter errorStream = Monitor.getStream();

    try {
            FileOutputStream fis;
            try {
                fis = AccessController.doPrivileged(
                        new PrivilegedExceptionAction<FileOutputStream>() {
                            public FileOutputStream run() throws IOException {
                                return new FileOutputStream(classFile);
                            }
                        });
            } catch (PrivilegedActionException pae) {
                throw (IOException) pae.getCause();
            }
      fis.write(bytecode.getArray(),
        bytecode.getOffset(), bytecode.getLength());
      fis.flush();
      if (t!=null) {       
        errorStream.printlnWithHeader(MessageService.getTextMessage(MessageId.CM_WROTE_CLASS_FILE, fullyQualifiedName, classFile, t));
      }
      fis.close();
    } catch (IOException e) {
      if (SanityManager.DEBUG)
        SanityManager.THROWASSERT("Unable to write .class file", e);
View Full Code Here

Examples of org.apache.derby.iapi.services.stream.HeaderPrintWriter

        logError( "\nERROR " +  se.getSQLState() + ": "  + se.getMessage() + "\n", se );
    }
    private static  void    logError( String errorMessage, Throwable t )
    {
      HeaderPrintWriter errorStream = Monitor.getStream();
      if (errorStream == null) {
        t.printStackTrace();
        return;
      }
      ErrorStringBuilder  errorStringBuilder = new ErrorStringBuilder(errorStream.getHeader());
      errorStringBuilder.append( errorMessage );
      errorStringBuilder.stackTrace( t );
      errorStream.print(errorStringBuilder.get().toString());
      errorStream.flush();
      errorStringBuilder.reset();
    }
View Full Code Here

Examples of org.apache.derby.iapi.services.stream.HeaderPrintWriter

   */
  private HeaderPrintWriter makeStream() {

    // get the header
    PrintWriterGetHeader header = makeHeader();
    HeaderPrintWriter hpw = makeHPW(header);

    // If hpw == null then no properties were specified for the stream
    // so use/create the default stream.
    if (hpw == null)
      hpw = createDefaultStream(header);
View Full Code Here

Examples of org.apache.derby.iapi.services.stream.HeaderPrintWriter

      try {
        Method theMethod = theClass.getMethod(methodName,  new Class[0]);

        if (!Modifier.isStatic(theMethod.getModifiers())) {
          HeaderPrintWriter hpw = useDefaultStream(header);
          hpw.printlnWithHeader(theMethod.toString() + " is not static");
          return hpw;
        }

        try {
          return makeValueHPW(theMethod, theMethod.invoke((Object) null,
View Full Code Here

Examples of org.apache.derby.iapi.services.stream.HeaderPrintWriter

      try {
        Field theField = theClass.getField(fieldName);
   
        if (!Modifier.isStatic(theField.getModifiers())) {
          HeaderPrintWriter hpw = useDefaultStream(header);
          hpw.printlnWithHeader(theField.toString() + " is not static");
          return hpw;
        }

        try {
          return makeValueHPW(theField, theField.get((Object) null),
View Full Code Here

Examples of org.apache.derby.iapi.services.stream.HeaderPrintWriter

    if (value instanceof OutputStream)
       return new BasicHeaderPrintWriter((OutputStream) value, header, false, name);
    else if (value instanceof Writer)
       return new BasicHeaderPrintWriter((Writer) value, header, false, name);
   
    HeaderPrintWriter hpw = useDefaultStream(header);

    if (value == null)
      hpw.printlnWithHeader(whereFrom.toString() + "=null");
    else
      hpw.printlnWithHeader(whereFrom.toString() + " instanceof " + value.getClass().getName());

    return hpw;
  }
View Full Code Here

Examples of org.apache.derby.iapi.services.stream.HeaderPrintWriter

    return new BasicHeaderPrintWriter(System.err, header, false, "System.err");
  }

  private HeaderPrintWriter useDefaultStream(PrintWriterGetHeader header, Throwable t) {

    HeaderPrintWriter hpw = useDefaultStream(header);
    hpw.printlnWithHeader(t.toString());
    return hpw;
  }
View Full Code Here

Examples of org.apache.derby.iapi.services.stream.HeaderPrintWriter

    filename = filename + ".class";

    final File classFile = new File(dir,filename);

    // find the error stream
    HeaderPrintWriter errorStream = Monitor.getStream();
    FileOutputStream fos = null;
    try {
      try {
        fos =  (FileOutputStream)AccessController.doPrivileged(
            new PrivilegedExceptionAction() {
              public Object run()
              throws FileNotFoundException {
                return new FileOutputStream(classFile);
              }
            });
      } catch (PrivilegedActionException pae) {
        throw (FileNotFoundException)pae.getCause();
      }
      fos.write(bytecode.getArray(),
        bytecode.getOffset(), bytecode.getLength());
      fos.flush();
      if (logMessage) {
        errorStream.printlnWithHeader("Wrote class "+getFullName()+" to file "+classFile.toString()+". Please provide support with the file and the following exception message: "+t);
      }
      fos.close();
    } catch (IOException e) {
      if (SanityManager.DEBUG)
        SanityManager.THROWASSERT("Unable to write .class file", e);
View Full Code Here

Examples of org.apache.derby.iapi.services.stream.HeaderPrintWriter

      String sqlstate = se.getSQLState();
      if ((sqlstate != null) && (sqlstate.equals(SQLState.LOGIN_FAILED)) &&
          (message != null) && (message.equals("Connection refused : java.lang.OutOfMemoryError")))       
        return;

      HeaderPrintWriter errorStream = Monitor.getStream();
      if (errorStream == null) {
        se.printStackTrace();
        return;
      }
      ErrorStringBuilder  errorStringBuilder = new ErrorStringBuilder(errorStream.getHeader());
      errorStringBuilder.append("\nERROR " +  se.getSQLState() + ": "  + se.getMessage() + "\n");
      errorStringBuilder.stackTrace(se);
      errorStream.print(errorStringBuilder.get().toString());
      errorStream.flush();
      errorStringBuilder.reset();

    }
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.