fmt.output(doc, outStream);
}
public void openCmdl(InputStream inputstream, FComponent featureModel) throws IOException, JDOMException {
FeatureModel fm = (FeatureModel) featureModel.getInterface(de.FeatureModellingTool.FeatureModel.Manager.FEATURE_MODEL_INTERFACE);
ConstraintModel cm = (ConstraintModel) featureModel.getInterface(de.FeatureModellingTool.FeatureModel.Manager.CONSTRAINT_MODEL_INTERFACE);
ConstraintModelEditor cme = (ConstraintModelEditor) featureModel.getInterface(de.FeatureModellingTool.FeatureModel.Manager.CONSTRAINT_MODEL_EDITOR_INTERFACE);
CompositeConstraintEditor plce = (CompositeConstraintEditor) featureModel.getInterface(de.FeatureModellingTool.FeatureModel.Manager.PL_CONSTRAINT_EDITOR_INTERFACE);
GroupConstraintEditor gce = (GroupConstraintEditor) featureModel.getInterface(de.FeatureModellingTool.FeatureModel.Manager.GROUP_CONSTRAINT_EDITOR_INTERFACE);
VPConstraintEditor vpce = (VPConstraintEditor) featureModel.getInterface(de.FeatureModellingTool.FeatureModel.Manager.VP_CONSTRAINT_EDITOR_INTERFACE);
//
Namespace cmd = Namespace.getNamespace("cmd", "http://sei.pku.edu.cn/DomainEngineering/constraintmodel");
SAXBuilder saxBuilder = new SAXBuilder(false);
Document doc = saxBuilder.build(inputstream);
Element root = doc.getRootElement();
//��ȡԼ����Ϣ
Element constraintList = root.getChild("constraintList", cmd);
Iterator constraintIterator = constraintList.getChildren("constraint", cmd).iterator();
while (constraintIterator.hasNext()) {
Element constraintElement = (Element) constraintIterator.next();
String id = constraintElement.getAttributeValue("id");
CompositeConstraint constraint = cme.addCompositeConstraint(id);
plce.setPLType(constraint, CompositeConstraintType.getInstance(constraintElement.getChild("plType").getTextNormalize()));
plce.setSourceType(constraint, CompositeConstraintPortType.getInstance(constraintElement.getChild("sourceType").getTextNormalize()));
plce.setSinkType(constraint, CompositeConstraintPortType.getInstance(constraintElement.getChild("sinkType").getTextNormalize()));
}
Element compositeConstraintList = constraintList.getChild("compositeConstraintList", cmd);
if (compositeConstraintList != null) {
Iterator compositeConstraintIterator = compositeConstraintList.getChildren("compositeConstraint", cmd).iterator();
while (compositeConstraintIterator.hasNext()) {
Element constraintElement = (Element) compositeConstraintIterator.next();
String id = constraintElement.getAttributeValue("id");
CompositeConstraint constraint = cme.addCompositeConstraint(id);
plce.setPLType(constraint, CompositeConstraintType.getInstance(constraintElement.getChild("plType").getTextNormalize()));
plce.setSourceType(constraint, CompositeConstraintPortType.getInstance(constraintElement.getChild("sourceType").getTextNormalize()));
plce.setSinkType(constraint, CompositeConstraintPortType.getInstance(constraintElement.getChild("sinkType").getTextNormalize()));
}
}
Element groupConstraintList = constraintList.getChild("groupConstraintList", cmd);
if (groupConstraintList != null) {
Iterator groupConstraintIterator = groupConstraintList.getChildren("groupConstraint", cmd).iterator();
while (groupConstraintIterator.hasNext()) {
Element constraintElement = (Element) groupConstraintIterator.next();
String id = constraintElement.getAttributeValue("id");
GroupConstraint constraint = cme.addGroupConstraint(id);
gce.setType(constraint, GroupConstraintType.getInstance(constraintElement.getChild("groupType").getTextNormalize()));
}
}
Element vpConstraintList = constraintList.getChild("vpConstraintList", cmd);
if (vpConstraintList != null) {
Iterator vpConstraintIterator = vpConstraintList.getChildren("vpConstraint", cmd).iterator();
while (vpConstraintIterator.hasNext()) {
Element constraintElement = (Element) vpConstraintIterator.next();
String id = constraintElement.getAttributeValue("id");
VPConstraint constraint = cme.addVPConstraint(id);
vpce.setType(constraint, VPConstraintType.getInstance(constraintElement.getChild("vpType").getTextNormalize()));
}
}
//��ȡ��ϵ��Ϣ
Element relationList = root.getChild("relationList", cmd);
Iterator plRelationIterator = relationList.getChildren("plRelation", cmd).iterator();
while (plRelationIterator.hasNext()) {
Element plRelationElement = (Element) plRelationIterator.next();
String id = plRelationElement.getAttributeValue("id");
String constraintID = plRelationElement.getChild("constraintID").getTextNormalize();
String featureID = plRelationElement.getChild("featureID").getTextNormalize();
String isSource = plRelationElement.getChild("isSource").getTextNormalize();
Element element = plRelationElement.getChild("modifier");
String modifier = null;
if (element != null) {
modifier = element.getTextNormalize();
} else {
modifier = CFRModifier.Affirmation.getName();
}
CFRelation plRelation = cme.addCFRelation(id, fm.getFeature(featureID), cm.getConstraint(constraintID), Boolean.valueOf(isSource).booleanValue(), CFRModifier.getInstance(modifier));
}
}