1 13 package com.tonbeller.jpivot.xmla; 14 15 import com.tonbeller.jpivot.olap.model.Dimension; 16 import com.tonbeller.jpivot.olap.model.Level; 17 18 21 public class XMLA_MemberProp { 22 23 private String caption; 24 private Level level; 25 private Dimension dimension; 26 private String name; 27 private String xmlTag; 28 29 private boolean sap = false; 30 31 34 public XMLA_MemberProp(String name, String caption, Level level) { 35 this.name = name; 36 this.caption = caption; 37 this.level = level; 38 this.sap = false; 39 this.dimension = level.getHierarchy().getDimension(); 40 xmlTag = escapeSpecialChars(name); 42 43 } 44 45 48 public XMLA_MemberProp(String name, String caption, Dimension dimension) { 49 this.name = name; 50 this.caption = caption; 51 this.level = null; 52 this.sap = true; 53 this.dimension = dimension; 54 xmlTag = escapeSpecialChars(name); 56 57 int len = xmlTag.length(); 59 if (xmlTag.charAt(0) == '[' && xmlTag.charAt(len - 1) == ']') 60 xmlTag = xmlTag.substring(1, len - 1); if (xmlTag.charAt(0) != '_') 63 xmlTag = "_" + xmlTag; 64 } 65 66 69 public Level getLevel() { 70 return level; 71 } 72 73 76 public String getName() { 77 return name; 78 } 79 80 83 public String getXmlTag() { 84 return xmlTag; 85 } 86 87 90 static final char[] special = { ' ', '<', '>' }; 91 private String escapeSpecialChars(String str) { 92 93 StringBuffer sb = new StringBuffer (); 94 Outer : for (int i = 0; i < str.length(); i++) { 95 char c = str.charAt(i); 96 for (int j = 0; j < special.length; j++) { 97 if (c == special[j]) { 98 sb.append("_x"); 99 String x = Integer.toHexString(c); 100 int k = 4 - x.length(); 101 105 for (int m = 0; m < k; m++) 106 sb.append('0'); 107 sb.append(x); 108 sb.append("_"); 109 continue Outer; 110 } 111 } 112 sb.append(c); 113 } 114 return sb.toString(); 115 } 116 117 120 public String getCaption() { 121 return caption; 122 } 123 124 127 public Dimension getDimension() { 128 return dimension; 129 } 130 131 } | Popular Tags |