Search in sources :

Example 6 with DataConversionException

use of org.jdom.DataConversionException in project intellij-community by JetBrains.

the class ReplaceOptions method readExternal.

public void readExternal(Element element) {
    matchOptions.readExternal(element);
    Attribute attribute = element.getAttribute(REFORMAT_ATTR_NAME);
    try {
        myToReformatAccordingToStyle = attribute.getBooleanValue();
    } catch (DataConversionException ex) {
    }
    attribute = element.getAttribute(SHORTEN_FQN_ATTR_NAME);
    try {
        toShortenFQN = attribute.getBooleanValue();
    } catch (DataConversionException ex) {
    }
    attribute = element.getAttribute(USE_STATIC_IMPORT_ATTR_NAME);
    if (attribute != null) {
        // old saved configurations without this attribute present
        try {
            myToUseStaticImport = attribute.getBooleanValue();
        } catch (DataConversionException ignore) {
        }
    }
    replacement = element.getAttributeValue(REPLACEMENT_ATTR_NAME);
    List<Element> elements = element.getChildren(VARIABLE_DEFINITION_TAG_NAME);
    if (elements != null && elements.size() > 0) {
        for (final Element element1 : elements) {
            final ReplacementVariableDefinition variableDefinition = new ReplacementVariableDefinition();
            variableDefinition.readExternal(element1);
            addVariableDefinition(variableDefinition);
        }
    }
}
Also used : ReplacementVariableDefinition(com.intellij.structuralsearch.ReplacementVariableDefinition) Attribute(org.jdom.Attribute) Element(org.jdom.Element) DataConversionException(org.jdom.DataConversionException)

Example 7 with DataConversionException

use of org.jdom.DataConversionException in project intellij-community by JetBrains.

the class MatchVariableConstraint method readExternal.

public void readExternal(Element element) {
    super.readExternal(element);
    Attribute attribute;
    attribute = element.getAttribute(REGEXP);
    if (attribute != null) {
        regExp = attribute.getValue();
    }
    attribute = element.getAttribute(NAME_OF_EXPRTYPE);
    if (attribute != null) {
        nameOfExprType = attribute.getValue();
    }
    attribute = element.getAttribute(NAME_OF_FORMALTYPE);
    if (attribute != null) {
        nameOfFormalArgType = attribute.getValue();
    }
    attribute = element.getAttribute(NAME_OF_REFEENCE_VAR);
    if (attribute != null) {
        nameOfReferenceVar = attribute.getValue();
    }
    attribute = element.getAttribute(WITHIN_HIERARCHY);
    if (attribute != null) {
        try {
            withinHierarchy = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(EXPRTYPE_WITHIN_HIERARCHY);
    if (attribute != null) {
        try {
            exprTypeWithinHierarchy = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(FORMALTYPE_WITHIN_HIERARCHY);
    if (attribute != null) {
        try {
            formalArgTypeWithinHierarchy = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(NEGATE_NAME_CONDITION);
    if (attribute != null) {
        try {
            invertRegExp = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(NEGATE_EXPRTYPE_CONDITION);
    if (attribute != null) {
        try {
            invertExprType = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(NEGATE_FORMALTYPE_CONDITION);
    if (attribute != null) {
        try {
            invertFormalType = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(NEGATE_READ_CONDITION);
    if (attribute != null) {
        try {
            invertReadAccess = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(NEGATE_WRITE_CONDITION);
    if (attribute != null) {
        try {
            invertWriteAccess = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(READ);
    if (attribute != null) {
        try {
            readAccess = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(WRITE);
    if (attribute != null) {
        try {
            writeAccess = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(TARGET);
    if (attribute != null) {
        try {
            partOfSearchResults = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(MIN_OCCURS);
    if (attribute != null) {
        try {
            minCount = attribute.getIntValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(MAX_OCCURS);
    if (attribute != null) {
        try {
            maxCount = attribute.getIntValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(WHOLE_WORDS_ONLY);
    if (attribute != null) {
        try {
            wholeWordsOnly = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(NEGATE_WITHIN_CONDITION);
    if (attribute != null) {
        try {
            invertWithinConstraint = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(NEGATE_CONTAINS_CONDITION);
    if (attribute != null) {
        try {
            invertContainsConstraint = attribute.getBooleanValue();
        } catch (DataConversionException ex) {
        }
    }
    attribute = element.getAttribute(CONTAINS_CONDITION);
    if (attribute != null)
        containsConstraint = attribute.getValue();
    attribute = element.getAttribute(WITHIN_CONDITION);
    if (attribute != null)
        withinConstraint = attribute.getValue();
}
Also used : Attribute(org.jdom.Attribute) DataConversionException(org.jdom.DataConversionException)

Example 8 with DataConversionException

use of org.jdom.DataConversionException in project vcell by virtualcell.

the class OptXmlReader method getOptimizationResultSet.

public static OptSolverResultSet getOptimizationResultSet(String xmlString) {
    Element optResultSetElement = stringToXML(xmlString);
    if (!optResultSetElement.getName().equals(OptXmlTags.OptSolverResultSet_Tag)) {
        throw new RuntimeException("unexpected element '" + optResultSetElement.getName() + "', expecting " + OptXmlTags.OptSolverResultSet_Tag);
    }
    List<Element> paramElementList = optResultSetElement.getChildren(OptXmlTags.Parameter_Tag);
    String[] parameterNames = new String[paramElementList.size()];
    int count = 0;
    for (Element parameterElement : paramElementList) {
        parameterNames[count] = parameterElement.getAttributeValue(OptXmlTags.ParameterName_Attr);
        count++;
    }
    Element bestRunElement = optResultSetElement.getChild(OptXmlTags.bestOptRunResultSet_Tag);
    try {
        OptRunResultSet bestResultSet = getOptRunResultSet(bestRunElement);
        OptSolverResultSet optResultSet = new OptSolverResultSet(parameterNames, bestResultSet);
        return optResultSet;
    } catch (DataConversionException e) {
        e.printStackTrace(System.out);
        throw new RuntimeException(e.getMessage());
    }
}
Also used : Element(org.jdom.Element) OptRunResultSet(cbit.vcell.opt.OptSolverResultSet.OptRunResultSet) DataConversionException(org.jdom.DataConversionException) OptSolverResultSet(cbit.vcell.opt.OptSolverResultSet)

Example 9 with DataConversionException

use of org.jdom.DataConversionException in project vcell by virtualcell.

the class XmlReader method getMathOverrides.

/**
 * This method returns a MathOverrides object from a XML Element.
 * Creation date: (5/21/2001 3:05:17 PM)
 * @return cbit.vcell.solver.MathOverrides
 * @param param org.jdom.Element
 */
private MathOverrides getMathOverrides(Element param, Simulation simulation) throws XmlParseException {
    MathOverrides mathOverrides = null;
    try {
        // Get the constants
        Object[] elements = param.getChildren().toArray();
        Vector<ConstantArraySpec> v1 = new Vector<ConstantArraySpec>();
        Vector<Constant> v2 = new Vector<Constant>();
        for (int i = 0; i < elements.length; i++) {
            Element e = (Element) elements[i];
            Attribute array = e.getAttribute(XMLTags.ConstantArraySpec);
            if (array != null) {
                // collect scan overrides
                String name = e.getAttributeValue(XMLTags.NameAttrTag);
                int type = array.getIntValue();
                v1.add(ConstantArraySpec.createFromString(name, e.getText(), type));
            } else {
                // collect regular overrides
                v2.add(getConstant(e));
            }
        }
        Constant[] constants = (Constant[]) BeanUtils.getArray(v2, Constant.class);
        ConstantArraySpec[] specs = (ConstantArraySpec[]) BeanUtils.getArray(v1, ConstantArraySpec.class);
        // create new MathOverrides object
        mathOverrides = new MathOverrides(simulation, constants, specs);
    } catch (ExpressionException e) {
        e.printStackTrace();
        throw new XmlParseException("A ExpressionException was fired when adding a Constant to the MathOverrides", e);
    } catch (DataConversionException e2) {
        e2.printStackTrace();
        throw new XmlParseException("A DataConversionException occured when reading a ConstantArraySpec type", e2);
    }
    return mathOverrides;
}
Also used : Attribute(org.jdom.Attribute) MacroscopicRateConstant(cbit.vcell.math.MacroscopicRateConstant) Constant(cbit.vcell.math.Constant) Element(org.jdom.Element) ConstantArraySpec(cbit.vcell.solver.ConstantArraySpec) ExpressionException(cbit.vcell.parser.ExpressionException) MathOverrides(cbit.vcell.solver.MathOverrides) VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) PointObject(cbit.vcell.mapping.spatial.PointObject) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject) CSGObject(cbit.vcell.geometry.CSGObject) DataConversionException(org.jdom.DataConversionException) Vector(java.util.Vector)

Aggregations

DataConversionException (org.jdom.DataConversionException)9 Attribute (org.jdom.Attribute)8 Element (org.jdom.Element)5 CSGObject (cbit.vcell.geometry.CSGObject)1 PointObject (cbit.vcell.mapping.spatial.PointObject)1 SpatialObject (cbit.vcell.mapping.spatial.SpatialObject)1 SurfaceRegionObject (cbit.vcell.mapping.spatial.SurfaceRegionObject)1 VolumeRegionObject (cbit.vcell.mapping.spatial.VolumeRegionObject)1 Constant (cbit.vcell.math.Constant)1 MacroscopicRateConstant (cbit.vcell.math.MacroscopicRateConstant)1 OptSolverResultSet (cbit.vcell.opt.OptSolverResultSet)1 OptRunResultSet (cbit.vcell.opt.OptSolverResultSet.OptRunResultSet)1 ExpressionException (cbit.vcell.parser.ExpressionException)1 ConstantArraySpec (cbit.vcell.solver.ConstantArraySpec)1 MathOverrides (cbit.vcell.solver.MathOverrides)1 ReplacementVariableDefinition (com.intellij.structuralsearch.ReplacementVariableDefinition)1 ArrayList (java.util.ArrayList)1 Vector (java.util.Vector)1