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 Message3 extends Message { 25 26 protected Message3(Type type, String fmt) { 27 super(type, fmt, 3); 28 } 29 30 protected TreeLogger branch3(TreeLogger logger, Object arg1, Object arg2, 31 Object arg3, Formatter fmt1, Formatter fmt2, Formatter fmt3, 32 Throwable caught) { 33 return logger.branch(type, compose3(arg1, arg2, arg3, fmt1, fmt2, fmt3), 34 caught); 35 } 36 37 protected String compose3(Object arg1, Object arg2, Object arg3, 38 Formatter fmt1, Formatter fmt2, Formatter fmt3) { 39 40 String stringArg1 = (arg1 != null ? fmt1.format(arg1) : "null"); 43 String stringArg2 = (arg2 != null ? fmt2.format(arg2) : "null"); 44 String stringArg3 = (arg3 != null ? fmt3.format(arg3) : "null"); 45 46 String insert1 = (argIndices[0] == 0) ? stringArg1 : ((argIndices[0] == 1) 50 ? stringArg2 : stringArg3); 51 String insert2 = (argIndices[1] == 1) ? stringArg2 : ((argIndices[1] == 0) 52 ? stringArg1 : stringArg3); 53 String insert3 = (argIndices[2] == 2) ? stringArg3 : ((argIndices[2] == 0) 54 ? stringArg1 : stringArg2); 55 56 int lenInsert1 = insert1.length(); 59 int lenInsert2 = insert2.length(); 60 int lenInsert3 = insert3.length(); 61 62 int lenPart0 = fmtParts[0].length; 65 int lenPart1 = fmtParts[1].length; 66 int lenPart2 = fmtParts[2].length; 67 int lenPart3 = fmtParts[3].length; 68 69 int dest = 0; 72 char[] chars = new char[minChars + lenInsert1 + lenInsert2 + lenInsert3]; 73 74 System.arraycopy(fmtParts[0], 0, chars, dest, lenPart0); 76 dest += lenPart0; 77 78 insert1.getChars(0, lenInsert1, chars, dest); 79 dest += lenInsert1; 80 81 System.arraycopy(fmtParts[1], 0, chars, dest, lenPart1); 83 dest += lenPart1; 84 85 insert2.getChars(0, lenInsert2, chars, dest); 86 dest += lenInsert2; 87 88 System.arraycopy(fmtParts[2], 0, chars, dest, lenPart2); 90 dest += lenPart2; 91 92 insert3.getChars(0, lenInsert3, chars, dest); 93 dest += lenInsert3; 94 95 System.arraycopy(fmtParts[3], 0, chars, dest, lenPart3); 97 98 return new String (chars); 99 } 100 101 protected void log3(TreeLogger logger, Object arg1, Object arg2, Object arg3, 102 Formatter fmt1, Formatter fmt2, Formatter fmt3, Throwable caught) { 103 if (logger.isLoggable(type)) { 104 logger.log(type, compose3(arg1, arg2, arg3, fmt1, fmt2, fmt3), caught); 105 } 106 } 107 } 108 | Popular Tags |