📄 xmla_member.java
字号:
public String getParentUniqueName() {
return parentUniqueName;
}
/**
* Returns the level.
* @return XMLA_Level
*/
public Level getLevel() {
return level;
}
/**
* set the Level
*/
public void setLevel(XMLA_Level level) {
this.level = level;
}
/**
* @see com.tonbeller.jpivot.olap.model.PropertyHolder#getProperties()
*/
public Property[] getProperties() {
/*
if (!propsOk) {
propsOk = true;
// if this member's level does not have properties at all
if (isCalculated || level.getProps().size() == 0) {
properties.clear();
} else {
try {
model.completeMember(this);
} catch (OlapException e) {
logger.error("?", e);
}
}
}
*/
if (isCalculated || properties.size() == 0)
return new Property[0]; // or null ???
return (Property[]) properties.toArray(new Property[0]);
}
/**
* @see com.tonbeller.jpivot.olap.model.PropertyHolder#getProperty(String)
*/
public Property getProperty(String name) {
/*
if (!propsOk) {
propsOk = true;
// if this member's level does not have properties at all
if (isCalculated || level.getProps().size() == 0) {
properties.clear();
} else {
try {
model.completeMember(this);
} catch (OlapException e) {
logger.error("?", e);
}
}
}
*/
if (isCalculated || properties.size() == 0)
return null;
for (int i = 0; i < properties.size(); i++) {
Property prop = (Property) properties.get(i);
if (name.equals(prop.getName()))
return prop;
}
return null; // not found
}
/**
* @see com.tonbeller.jpivot.olap.model.Member#getRootDistance()
*/
public int getRootDistance() {
if (level == null && isCalculated)
return 0;
return level.getDepth();
}
/**
* get level number = depth of member
* @return int
*/
public int getDepth() {
if (level == null && isCalculated)
return 0;
return this.level.getDepth(); // level number is depth
}
/**
*
* @return XMLA_Member[]
*/
public XMLA_Member[] getChildren() throws OlapException {
if (childrenOk) {
if (childrenCardinality == 0)
return new XMLA_Member[0];
else
return (XMLA_Member[]) aChildren.toArray(new XMLA_Member[0]);
}
// determine children
model.retrieveMemberChildren(this); // will retrieve children
return (XMLA_Member[]) aChildren.toArray(new XMLA_Member[0]);
}
/**
* set list of children.
* @param aNewChildren List of children to be added
*/
public void setChildren(ArrayList aChildren) {
this.aChildren = aChildren;
if (aChildren == null)
childrenCardinality = 0;
else
childrenCardinality = aChildren.size();
}
/**
* Returns the complete.
* @return boolean
*/
public boolean isComplete() {
return complete;
}
/**
* Returns the parent.
* @return XMLA_Member
*/
public Member getParent() throws OlapException {
if (parentOk)
return parent;
/*
if (isCalculated) {
//get the parent by unique name
String[] names = uniqueName.split("\\.");
if (names.length <= 2) {
// no parent in unique name
parentOk = true;
parent = null;
return null;
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < names.length - 1; i++) {
if (i > 0)
sb.append('.');
sb.append(names[i]);
}
parentUniqueName = sb.toString();
parent = model.lookupMemberByUName(parentUniqueName);
parentOk = true;
return parent;
}
*/
if (model.isMicrosoft() || isCalculated) {
parentUniqueName = StringUtil.parentFromUName(uniqueName);
if (parentUniqueName == null) {
parent = null;
parentOk = true;
return parent;
} else {
parent = (XMLA_Member) model.lookupMemberByUName(parentUniqueName);
if (parent != null) {
parentOk = true;
return parent;
}
}
}
// this call should not be needed
model.retrieveMemberParent(this);
return parent;
}
/**
* get Dimension of member
* @return dimension
*/
public Dimension getDimension() {
if (level != null)
return level.getHierarchy().getDimension();
Dimension dim = model.lookupDimByUName(dimUName);
return dim;
}
/**
* Sets the parent.
* @param parent The parent to set
*/
public void setParent(XMLA_Member parent) {
this.parent = parent;
this.parentOk = true;
}
/**
* get hierarchy of member
* @return Hierarchy
*/
public Hierarchy getHierarchy() {
if (level != null)
return level.getHierarchy();
XMLA_Dimension dim = (XMLA_Dimension) getDimension();
String defHier = dim.getDefaultHier();
if (defHier != null && defHier.length() > 0)
return model.lookupHierByUName(defHier);
else
return null;
}
/**
* Returns the isCalculated.
* @return boolean
*/
public boolean isCalculated() {
return isCalculated;
}
/**
* @return the unique name
*/
public String toMdx() {
return this.uniqueName;
}
/**
* @see com.tonbeller.jpivot.olap.mdxparse.Exp#clone()
* probably not needed
*/
public Object clone() {
String[] nameParts = StringUtil.splitUniqueName(uniqueName);
CompoundId clone = new CompoundId(nameParts[0], false);
for (int i = 1; i < nameParts.length; i++) {
clone.append(nameParts[i], false);
}
return clone;
}
/**
* add a property
*/
public void addProp(Property prop) {
properties.add(prop);
}
/**
* clear properties
*/
public void clearProps() {
properties.clear();
}
/**
* @return
*/
public boolean isPropsOk() {
return propsOk;
}
/**
* @param b
*/
public void setPropsOk(boolean b) {
propsOk = b;
}
/**
* @return
*/
public boolean isChildrenOk() {
return childrenOk;
}
/**
* @return
*/
public boolean isParentOk() {
return parentOk;
}
/**
* @param b
*/
public void setChildrenOk(boolean b) {
childrenOk = b;
}
/**
* @param b
*/
public void setParentOk(boolean b) {
parentOk = b;
}
/**
* @return true , if the model is SAP
*/
public boolean isSAP() {
return model.isSAP();
}
public boolean isMicrosoft() {
return model.isMicrosoft();
}
public boolean isMondrian() {
return model.isMondrian();
}
/**
* @see com.tonbeller.jpivot.olap.mdxparse.Exp#accept
*/
public void accept(ExpVisitor visitor) {
visitor.visitMember(this);
}
/**
* @return displayInfo
*/
public long getDisplayInfo() {
return displayInfo;
}
/**
* @param displayInfo string
*/
public void setDisplayInfo(String strDisplayInfo) {
if (strDisplayInfo == null || displayInfo != -1)
return;
displayInfo = Long.parseLong(strDisplayInfo);
// the two least significant bytes is the children cardinality
if (childrenCardinality == -1)
childrenCardinality = Math.abs(displayInfo) % 65536;
}
/**
* @return true, if it is an "All" member
*/
public boolean isAll() {
return ((XMLA_Level)this.getLevel()).isAll();
}
} // End XMLA_Member
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -