1 28 package net.sf.jasperreports.engine; 29 30 import java.util.Arrays ; 31 import java.util.Iterator ; 32 import java.util.List ; 33 import java.util.StringTokenizer ; 34 35 36 40 public class JRPrintElementIndex 41 { 42 43 44 47 private int reportIndex = 0; 48 private int pageIndex = 0; 49 private List elementIndexes = null; 50 51 52 55 public JRPrintElementIndex( 56 int reportIndex, 57 int pageIndex, 58 Integer [] elementIndexes 59 ) 60 { 61 this.reportIndex = reportIndex; 62 this.pageIndex = pageIndex; 63 this.elementIndexes = Arrays.asList(elementIndexes); 64 } 65 66 67 70 public int getReportIndex() 71 { 72 return this.reportIndex; 73 } 74 75 76 79 public int getPageIndex() 80 { 81 return this.pageIndex; 82 } 83 84 85 88 public Integer [] getElementIndexes() 89 { 90 return (Integer []) elementIndexes.toArray(new Integer [elementIndexes.size()]); 91 } 92 93 94 102 public String toString() 103 { 104 StringBuffer str = new StringBuffer (); 105 str.append(reportIndex); 106 str.append('_'); 107 str.append(pageIndex); 108 for (Iterator it = elementIndexes.iterator(); it.hasNext();) 109 { 110 Integer idx = (Integer ) it.next(); 111 str.append('_'); 112 str.append(idx); 113 } 114 return str.toString(); 115 } 116 117 118 125 public static JRPrintElementIndex parsePrintElementIndex(String indexStr) 126 { 127 StringTokenizer tkzer = new StringTokenizer (indexStr, "_"); 128 129 int reportIndex = Integer.parseInt(tkzer.nextToken()); 130 int pageIndex = Integer.parseInt(tkzer.nextToken()); 131 132 Integer [] elementIndexes = new Integer [tkzer.countTokens()]; 133 int c = 0; 134 while (tkzer.hasMoreTokens()) 135 { 136 elementIndexes[c++] = Integer.valueOf(tkzer.nextToken()); 137 } 138 139 return 140 new JRPrintElementIndex( 141 reportIndex, 142 pageIndex, 143 elementIndexes 144 ); 145 } 146 } 147 | Popular Tags |