use of org.jdom.Attribute in project intellij-plugins by StepicOrg.
the class StudySerializationUtils method getSectionNodes.
private static List<Element> getSectionNodes(@NotNull Element stepManager) throws StudyUnrecognizedFormatException {
Element defaultLang = getFieldWithNameOrNull(stepManager, DEFAULT_LANG);
if (defaultLang == null) {
defaultLang = createField(stepManager, DEFAULT_LANG, INVALID);
}
Attribute defaultLangValue = defaultLang.getAttribute(VALUE);
replaceLanguage(defaultLangValue);
Element courseNode = getCourseNode(stepManager);
return getListFieldWithNameOrNull(courseNode, SECTIONS_NODES, SECTION_NODE_CLASS);
}
use of org.jdom.Attribute in project intellij-plugins by JetBrains.
the class OsgiRunConfiguration method readExternal.
@Override
public void readExternal(final Element element) throws InvalidDataException {
workingDir = element.getAttributeValue(WORKING_DIR_ATTRIBUTE);
vmParameters = element.getAttributeValue(VM_PARAMETERS_ATTRIBUTE);
programParameters = element.getAttributeValue(PROGRAM_PARAMETERS_ATTRIBUTE);
includeAllBundlesInClassPath = Boolean.valueOf(element.getAttributeValue(INCLUDE_ALL_BUNDLES_IN_CLASS_PATH_ATTRIBUTE, "false"));
useAlternativeJre = Boolean.valueOf(element.getAttributeValue(USE_ALTERNATIVE_JRE_ATTRIBUTE, "false"));
alternativeJrePath = element.getAttributeValue(ALTERNATIVE_JRE_PATH, "");
generateWorkingDir = Boolean.valueOf(element.getAttributeValue(GENERATE_WORKING_DIR_ATTRIBUTE));
try {
frameworkStartLevel = Integer.parseInt(element.getAttributeValue(FRAMEWORK_START_LEVEL, "1"));
} catch (NumberFormatException e) {
frameworkStartLevel = 1;
}
try {
defaultStartLevel = Integer.parseInt(element.getAttributeValue(DEFAULT_START_LEVEL, "5"));
} catch (NumberFormatException e) {
defaultStartLevel = 5;
}
List<Element> children = element.getChildren(BUNDLE_ELEMENT);
bundlesToDeploy.clear();
for (Element child : children) {
String name = child.getAttributeValue(NAME_ATTRIBUTE);
String url = child.getAttributeValue(URL_ATTRIBUTE);
String startLevel = child.getAttributeValue(START_LEVEL_ATTRIBUTE);
String typeName = child.getAttributeValue(TYPE_ATTRIBUTE);
SelectedBundle.BundleType type;
try {
type = SelectedBundle.BundleType.valueOf(typeName);
} catch (IllegalArgumentException e) {
LOG.error("unexpected bundle type '" + typeName + "'");
type = SelectedBundle.BundleType.Module;
}
String path = url != null ? VfsUtilCore.urlToPath(url) : null;
SelectedBundle selectedBundle = new SelectedBundle(type, name, path);
if (startLevel != null) {
try {
selectedBundle.setStartLevel(Integer.parseInt(startLevel));
} catch (NumberFormatException ignored) {
}
}
String startAfterInstallationString = child.getAttributeValue(START_AFTER_INSTALLATION_ATTRIBUTE);
if (startAfterInstallationString != null) {
selectedBundle.setStartAfterInstallation(Boolean.parseBoolean(startAfterInstallationString));
}
bundlesToDeploy.add(selectedBundle);
}
// try to load the framework instance
Element framework = element.getChild(FRAMEWORK_ELEMENT);
if (framework != null) {
String name = framework.getAttributeValue(INSTANCE_ATTRIBUTE);
if (name != null) {
ApplicationSettings settings = ServiceManager.getService(ApplicationSettings.class);
instanceToUse = settings.getFrameworkInstance(name);
}
}
Element additionalProperties = element.getChild(ADDITIONAL_PROPERTIES_ELEMENT);
if (additionalProperties == null) {
//noinspection SpellCheckingInspection
additionalProperties = element.getChild("additinalProperties");
}
if (additionalProperties != null) {
List<Attribute> attributes = additionalProperties.getAttributes();
for (Attribute attribute : attributes) {
this.additionalProperties.put(attribute.getName(), attribute.getValue());
}
}
super.readExternal(element);
}
use of org.jdom.Attribute 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;
}
use of org.jdom.Attribute in project vcell by virtualcell.
the class XmlTreeDiff method mergeAttrList.
/**
* This method merges to attributes list into one.
* Creation date: (8/29/2001 2:51:33 PM)
* @return java.util.List
* @param listA java.util.List
* @param listB java.util.List
*/
private List mergeAttrList(List listA, List listB, DiffConfiguration comparisonSetting) {
List result = new java.util.ArrayList();
XmlElementComparator comparator = new XmlElementComparator(this);
Iterator i = listA.iterator();
while (i.hasNext()) {
Attribute temp = (Attribute) (i.next());
if (temp.getName().equals(XMLTags.KeyValueAttrTag) && ignoreVersionInfo) {
if (DiffConfiguration.COMPARE_DOCS_SAVED == comparisonSetting) {
result.add(new NodeInfo(temp, NodeInfo.STATUS_NORMAL));
}
i.remove();
continue;
} else {
int index = comparator.getindexof(temp, listB);
if (index >= 0) {
// this attribute exists in both!
result.add(new NodeInfo(temp, NodeInfo.STATUS_NORMAL));
i.remove();
listB.remove(index);
}
}
}
// If there are already Attributes in ListA, try to find similars in ListB
i = listA.iterator();
while (i.hasNext()) {
Attribute temp = (Attribute) (i.next());
int index = comparator.getsimilarAttr(temp, listB);
if (index >= 0) {
result.add(new ChangedNodeInfo(temp, (Attribute) listB.get(index)));
// I found one similar
listB.remove(index);
} else {
// It seems that this nodes only exist in ListA
result.add(new NodeInfo(temp, NodeInfo.STATUS_REMOVED));
}
}
// Add the remaining of listB
i = listB.iterator();
while (i.hasNext()) {
// these nodes only exists in ListB
Attribute tempAtt = (Attribute) i.next();
if (tempAtt.getName().equals(XMLTags.KeyValueAttrTag) && ignoreVersionInfo) {
// ignore keys in the modified
if (DiffConfiguration.COMPARE_DOCS_OTHER == comparisonSetting) {
result.add(new NodeInfo((tempAtt), NodeInfo.STATUS_NORMAL));
}
continue;
}
result.add(new NodeInfo((tempAtt), NodeInfo.STATUS_NEW));
}
return result;
}
use of org.jdom.Attribute in project vcell by virtualcell.
the class XmlTreeDiff method createNodes.
/**
* Insert the method's description here.
* Creation date: (8/29/2001 2:41:50 PM)
* @return cbit.xml.merge.NodeInfo
* @param parsed org.jdom.Element
* @param status int
*/
private NodeInfo createNodes(org.jdom.Element parsed, int status, String nodeSource) {
NodeInfo parent = null;
NodeInfo temp;
if (parsed != null) {
parent = new NodeInfo(parsed, status);
// get all the attributes children
List children = parsed.getAttributes();
if (!children.isEmpty()) {
Iterator i = children.iterator();
while (i.hasNext()) {
Attribute atchild = (Attribute) i.next();
if (atchild.getName().equals(XMLTags.KeyValueAttrTag) && ignoreVersionInfo) {
// keep the read-only key values for the baseline.
if (nodeSource.equals(this.BASELINE_NODE)) {
parent.add(new NodeInfo(atchild, NodeInfo.STATUS_NORMAL));
} else {
// ignore all the modified key values.
continue;
}
} else {
parent.add(new NodeInfo(atchild, status));
}
}
}
// get all the element children
List elementchildren = parsed.getChildren();
if (!elementchildren.isEmpty()) {
Iterator i = elementchildren.iterator();
while (i.hasNext()) {
Element child = (Element) i.next();
// ignore all version info.
if (child.getName().equals(XMLTags.VersionTag) && ignoreVersionInfo) {
if (nodeSource.equals(BASELINE_NODE)) {
// keep the baseline versions, but they are all 'normal'
temp = createNodes(child, NodeInfo.STATUS_NORMAL, nodeSource);
parent.add(temp);
} else if (nodeSource.equals(MODIFIED_NODE)) {
// ignore version info for the modified.
continue;
}
} else {
temp = createNodes(child, status, nodeSource);
parent.add(temp);
}
}
}
}
return parent;
}
Aggregations