@Override public String getMathMLString() { if (isSetMath()) { return math.toMathML(); } return ""; }
@Override public int getChildCount() { return super.getChildCount() + (isSetMath() ? 1 : 0); }
@Override public boolean containsUndeclaredUnits() { return isSetMath() ? math.containsUndeclaredUnits() : false; }
@Override @Deprecated public String getFormula() { try { return isSetMath() ? getMath().toFormula() : ""; } catch (Throwable exc) { logger.warn(resourceBundle.getString("AbstractMathContainer.toFormula"), exc); return "invalid"; } }
@Override public TreeNode getChildAt(int index) { if (index < 0) { throw new IndexOutOfBoundsException(MessageFormat.format( resourceBundle.getString("IndexSurpassesBoundsException"), index, 0)); } int count = super.getChildCount(), pos = 0; if (index < count) { return super.getChildAt(index); } else { index -= count; } if (isSetMath()) { if (index == pos) { return getMath(); } pos++; } throw new IndexOutOfBoundsException(MessageFormat.format( resourceBundle.getString("IndexExceedsBoundsException"), index, Math.min(pos, 0))); }
@Override public Map<String, String> writeXMLAttributes() { Map<String, String> attributes = super.writeXMLAttributes(); if (isSetMath() && isSetLevel() && (getLevel() < 2)) { attributes.put("formula", getFormula()); } return attributes; }
/** * Creates a MathContainer instance from a given MathContainer. * * @param sb an {@code AbstractMathContainer} object to clone */ public AbstractMathContainer(AbstractMathContainer sb) { super(sb); if (sb.isSetMath()) { setMath(sb.getMath().clone()); } else { math = null; } }
@Override public UnitDefinition getDerivedUnitDefinition() { UnitDefinition ud = null; if (isSetMath()) { Model m = getModel(); ASTNode expandedMath = math;