1 16 package com.google.gwt.dev.util.msg; 17 18 import com.google.gwt.core.ext.TreeLogger; 19 import com.google.gwt.core.ext.TreeLogger.Type; 20 21 24 public abstract class Message2 extends Message { 25 26 public Message2(Type type, String fmt) { 27 super(type, fmt, 2); 28 } 29 30 protected TreeLogger branch2(TreeLogger logger, Object arg1, Object arg2, 31 Formatter fmt1, Formatter fmt2, Throwable caught) { 32 return logger.branch(type, compose2(arg1, arg2, fmt1, fmt2), caught); 33 } 34 35 protected String compose2(Object arg1, Object arg2, Formatter fmt1, 36 Formatter fmt2) { 37 38 String stringArg1 = (arg1 != null ? fmt1.format(arg1) : "null"); 41 String stringArg2 = (arg2 != null ? fmt2.format(arg2) : "null"); 42 43 String insert1 = (argIndices[0] == 0) ? stringArg1 : stringArg2; 47 String insert2 = (argIndices[1] == 1) ? stringArg2 : stringArg1; 48 49 int lenInsert1 = insert1.length(); 52 int lenInsert2 = insert2.length(); 53 54 int lenPart0 = fmtParts[0].length; 57 int lenPart1 = fmtParts[1].length; 58 int lenPart2 = fmtParts[2].length; 59 60 int dest = 0; 63 char[] chars = new char[minChars + lenInsert1 + lenInsert2]; 64 65 System.arraycopy(fmtParts[0], 0, chars, dest, lenPart0); 67 dest += lenPart0; 68 69 insert1.getChars(0, lenInsert1, chars, dest); 70 dest += lenInsert1; 71 72 System.arraycopy(fmtParts[1], 0, chars, dest, lenPart1); 74 dest += lenPart1; 75 76 insert2.getChars(0, lenInsert2, chars, dest); 77 dest += lenInsert2; 78 79 System.arraycopy(fmtParts[2], 0, chars, dest, lenPart2); 81 82 return new String (chars); 83 } 84 85 protected void log2(TreeLogger logger, Object arg1, Object arg2, 86 Formatter fmt1, Formatter fmt2, Throwable caught) { 87 if (logger.isLoggable(type)) { 88 logger.log(type, compose2(arg1, arg2, fmt1, fmt2), caught); 89 } 90 } 91 } 92 | Popular Tags |