⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlblasterexception.java

📁 java开源的企业总线.xmlBlaster
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                 this.cause instanceof ArrayIndexOutOfBoundsException ||                 this.cause instanceof StringIndexOutOfBoundsException ||                 this.cause instanceof ClassCastException ||                 this.cause instanceof OutOfMemoryError              );      try {         if (isInternal() || handleAsInternal) {            return MessageFormat.format(this.logFormatInternal, arguments);         }         else if (isResource()) {            return MessageFormat.format(this.logFormatResource, arguments);         }         else if (isCommunication()) {            return MessageFormat.format(this.logFormatCommunication, arguments);         }         else if (isUser()) {            return MessageFormat.format(this.logFormatUser, arguments);         }         else if (errorCodeEnum == ErrorCode.LEGACY) {            return MessageFormat.format(this.logFormatLegacy, arguments);         }         else {            return MessageFormat.format(this.logFormat, arguments);         }      }      catch (IllegalArgumentException e) {         log.severe("Please check your formatting string for exceptions, usually set by 'XmlBlasterException.logFormat=...'" +                   " as described in http://www.xmlblaster.org/xmlBlaster/doc/requirements/admin.errorcodes.html: " + e.toString() +                   "\nOriginal exception is: errorCode=" + errorCodeStr + " message=" + getRawMessage());         if (isInternal() || handleAsInternal) {            return MessageFormat.format(DEFAULT_LOGFORMAT_INTERNAL, arguments);         }         else if (isResource()) {            return MessageFormat.format(DEFAULT_LOGFORMAT, arguments);         }         else if (isCommunication()) {            return MessageFormat.format(DEFAULT_LOGFORMAT, arguments);         }         else if (isUser()) {            return MessageFormat.format(DEFAULT_LOGFORMAT, arguments);         }         else if (errorCodeEnum == ErrorCode.LEGACY) {            return MessageFormat.format(DEFAULT_LOGFORMAT, arguments);         }         else {            return MessageFormat.format(DEFAULT_LOGFORMAT, arguments);         }      }   }   /**    * Get the original message text, it is prefixed by the current subversion revision number.     * For example: "#12702M Can't find class MyPlugin"    * @return The original message text, never null    */   public final String getRawMessage() {      if (super.getMessage()!=null && super.getMessage().startsWith("#")) {         return super.getMessage();      }      String revision = "#" + glob.getRevisionNumber();      return (super.getMessage()==null) ? revision : revision + " " + super.getMessage();   }   /**    * A comma separated list with key/values containing detailed    * information about the server environment    */   public final String getVersionInfo() {      return this.versionInfo;   }   /**    * Timestamp when exception was thrown    * @return Never null    */   public final Timestamp getTimestamp() {      if (this.timestamp == null) {         this.timestamp = new Timestamp(this.timestampNanos);      }      return this.timestamp;   }   /**    * The original exception, note that this is not serialized.     * @return The original exception or null    */   public final Throwable getEmbeddedException() {      //return getCause(); // JDK 1.4 or better only      return this.cause;   }   /**    * @return The stack trace or null, e.g.    * <pre>    *  stackTrace= errorCode=internal.unknown message=Bla bla    *    at org.xmlBlaster.util.XmlBlasterException.main(XmlBlasterException.java:488)    * </pre>    * The first line is the result from toString() and the following lines    * are the stackTrace    */   public final String getStackTraceStr() {      return this.stackTrace;   }   /**    * @return The toString() of the embedded exception which is <classname>:getMessage()<br />    *         or null if not applicable    */   public final String getEmbeddedMessage() {      return this.embeddedMessage;   }   /**    * @return Not defined yet    */   public final String getTransactionInfo() {      return this.transactionInfo;   }   /**    * @return true if the exception occured on server side, false if happened on client side    */   public final boolean isServerSide() {      return this.isServerSide;   }   /**    * @param serverSide true to mark the exception has occurred on server side, false if happened on client side    */   public final void isServerSide(boolean serverSide) {      this.isServerSide = serverSide;   }   public boolean isInternal() {      return this.errorCodeStr.startsWith("internal");   }   public boolean isResource() {      return this.errorCodeStr.startsWith("resource");   }   public boolean isCommunication() {      return this.errorCodeStr.startsWith("communication");   }   public boolean isUser() {      return this.errorCodeStr.startsWith("user");   }   public boolean isTransaction() {      return this.errorCodeStr.startsWith("transaction");   }   public String createStackTrace() {      StringWriter sw = new StringWriter();      PrintWriter pw = new PrintWriter(sw);      if (this.cause != null) {         cause.printStackTrace(pw);      }      printStackTrace(pw);  // prints: toString() and in next lines the stack trace      return sw.toString().trim();   }   public static String createVersionInfo() {      StringBuffer buf = new StringBuffer(512);      buf.append("version=").append(Global.instance().getVersion()).append(",");      buf.append("revision=").append(Global.instance().getRevisionNumber()).append(",");      buf.append("os.name=").append(System.getProperty("os.name", "unknown").trim()).append(",");      buf.append("os.version=").append(System.getProperty("os.version", "unknown").trim()).append(",");      buf.append("java.vm.vendor=").append(System.getProperty("java.vm.vendor", "unknown").trim()).append(",");      buf.append("java.vm.version=").append(System.getProperty("java.vm.version", "unknown").trim()).append(",");      buf.append("os.arch=").append(System.getProperty("os.arch", "unknown").trim()).append(",");      buf.append("build.timestamp=").append(Global.instance().getBuildTimestamp()).append(",");      buf.append("build.java.vendor=").append(Global.instance().getBuildJavaVendor()).append(",");      buf.append("build.java.version=").append(Global.instance().getBuildJavaVersion()); // .append(",");      return buf.toString();   }   /**    * @deprecated Please use constructor which uses ErrorCode    */   public XmlBlasterException(String location, String message) {      this((Global)null, ErrorCode.LEGACY, location, message, (Throwable)null);   }   /**    * Caution: The syntax is used by parseToString() to parse the stringified exception again.<br />    * This is used by XmlRpc, see XmlRpcConnection.extractXmlBlasterException()    */   public String toString() {      //return getMessage();      String text = "errorCode=" + getErrorCodeStr() + " message=" + getRawMessage();      if (this.embeddedMessage != null && this.embeddedMessage.length() > 0) {         text += " : " + embeddedMessage;      }      return text;   }   /**    * Parsing what toString() produced   * @param glob   * @param toString The original exception   * @param fallback The error code to use if 'toString' is unparsable   */   public static XmlBlasterException parseToString(Global glob, String toString, ErrorCode fallback) {      String errorCode = toString;      String reason = toString;      int start = toString.indexOf("errorCode=");      int end = toString.indexOf(" message=");      if (start >= 0) {         if (end >= 0) {            try { errorCode = toString.substring(start+"errorCode=".length(), end); } catch(IndexOutOfBoundsException e1) {}         }         else {            try { errorCode = toString.substring(start+"errorCode=".length()); } catch(IndexOutOfBoundsException e2) {}         }      }      if (end >= 0) {         try { reason = toString.substring(end+" message=".length()); } catch(IndexOutOfBoundsException e3) {}      }      try {         return new XmlBlasterException(glob, ErrorCode.toErrorCode(errorCode), "XmlBlasterException", reason);      }      catch (IllegalArgumentException e) {         log.warning("Parsing exception string <" + toString + "> failed: " + e.toString());         return new XmlBlasterException(glob, fallback, "XmlBlasterException", toString);      }   }   /**    * @see #toXml(String)    */   public final String toXml() {      return toXml((String)null);   }   /**    * Create a XML representation of the Exception.    * <pre>    *   &lt;exception errorCode='resource.outOfMemory'>    *      &lt;class>JavaClass&lt;/class>    *      &lt;message>&lt;![cdata[  bla bla ]]>&lt;/message>    *   &lt;/exception>    * </pre>    */   public String toXml(String extraOffset) {      StringBuffer sb = new StringBuffer(getMessage().length() + 256);      if (extraOffset == null) extraOffset = "";      String offset = Constants.OFFSET + extraOffset;      sb.append(offset).append("<exception errorCode='").append(getErrorCodeStr()).append("'>");      sb.append(offset).append(" <class>").append(getClass().getName()).append("</class>");      sb.append(offset).append(" <isServerSide>").append(isServerSide()).append("</isServerSide>");      sb.append(offset).append(" <node>").append(getNode()).append("</node>");      sb.append(offset).append(" <location>").append(getLocation()).append("</location>");      sb.append(offset).append(" <lang>").append(getLang()).append("</lang>");      sb.append(offset).append(" <message><![CDATA[").append(getRawMessage()).append("]]></message>");      sb.append(offset).append(" <versionInfo>").append(getVersionInfo()).append("</versionInfo>");      sb.append(offset).append(" <timestamp>").append(getTimestamp().toString()).append("</timestamp>");      sb.append(offset).append(" <stackTrace><![CDATA[").append(getStackTraceStr()).append("]]></stackTrace>");      sb.append(offset).append(" <embeddedMessage><![CDATA[").append(getEmbeddedMessage()).append("]]></embeddedMessage>");      //sb.append(offset).append(" <transactionInfo><![CDATA[").append(getTransactionInfo()).append("]]></transactionInfo>");      sb.append(offset).append("</exception>");      return sb.toString();   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -