package de.FeatureModellingTool.FeatureModel.store;
import de.FeatureModellingTool.FeatureModel.*;
import java.io.IOException;
import java.io.OutputStream;
import java.io.InputStream;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Map;
import java.util.Iterator;
import org.jdom.Namespace;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
import component.FComponent;
import manager.ManagerInterface;
import manager.IllegalParameterException;
import model.FileModel;
/**
* Created by IntelliJ IDEA.
* User: saturn
* Date: 2003-6-28
* Time: 14:09:54
* To change this template use Options | File Templates.
*/
public class FmdlParserPrototype implements FmdlParser {
public Document buildCmdl(ConstraintModel constraintModel , FeatureModel featureModel){
// ����CMDL�������ռ�
Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
Namespace cmd = Namespace.getNamespace("cmd", "http://sei.pku.edu.cn/DomainEngineering/constraintmodel");
//����һ��������Ԫ��constraintModel��CMDL�ĵ�
Document doc = new Document(new Element("constraintModel", cmd));
//��ø�Ԫ�أ�������schemaLocation��name���ԣ����¶�FMDL�ĵ��IJ������Ը�Ԫ��Ϊ��
Element root = doc.getRootElement();
root.setAttribute("schemaLocation", "http://sei.pku.edu.cn/DomainEngineering/constraintmodel constraintmodel.xsd", xsi)
.setAttribute("name", featureModel.getName());
//���constraintListԪ��
Element constraintList = new Element("constraintList", cmd);
root.addContent(constraintList);
//���compositeConstraintList
Element compositeConstraintList = new Element("compositeConstraintList", cmd);
constraintList.addContent(compositeConstraintList);
//���groupConstraintList
Element groupConstraintList = new Element("groupConstraintList", cmd);
constraintList.addContent(groupConstraintList);
//���vpConstraintList
Element vpConstraintList = new Element("vpConstraintList", cmd);
constraintList.addContent(vpConstraintList);
//���relationListԪ��
Element relationList = new Element("relationList", cmd);
root.addContent(relationList);
//���λ�ȡÿ��Լ�����������ԣ���CMDL�ĵ��н���constraintԪ�أ��������������
//��constraintModel�л�ȡ����PLԼ��
Map allPLConstraint = constraintModel.getAllCompositeConstraint();
if (allPLConstraint != null) {
Iterator constraintIterator = allPLConstraint.values().iterator();
while (constraintIterator.hasNext()) {
CompositeConstraint constraint = (CompositeConstraint) constraintIterator.next();
String id = constraint.getID();
String plType = constraint.getPLType().getName();
String sourceType = constraint.getSourceType().getName();
String sinkType = constraint.getSinkType().getName();
Element constraintElement = new Element("compositeConstraint", cmd);
constraintElement.setAttribute("id", id);
constraintElement.addContent(new Element("plType").addContent(plType));
constraintElement.addContent(new Element("sourceType").addContent(sourceType));
constraintElement.addContent(new Element("sinkType").addContent(sinkType));
compositeConstraintList.addContent(constraintElement);
}
}
//��constraintModel�л�ȡ����GroupԼ��
Map allGroupConstraint = constraintModel.getAllGroupConstraint();
if (allGroupConstraint != null) {
Iterator constraintIterator = allGroupConstraint.values().iterator();
while (constraintIterator.hasNext()) {
GroupConstraint constraint = (GroupConstraint) constraintIterator.next();
String id = constraint.getID();
String groupType = constraint.getType().getName();
Element constraintElement = new Element("groupConstraint", cmd);
constraintElement.setAttribute("id", id);
constraintElement.addContent(new Element("groupType").addContent(groupType));
groupConstraintList.addContent(constraintElement);
}
}
//��constraintModel�л�ȡ����VPԼ��
Map allVPConstraint = constraintModel.getAllVPConstraint();
if (allVPConstraint != null) {
Iterator constraintIterator = allVPConstraint.values().iterator();
while (constraintIterator.hasNext()) {
VPConstraint constraint = (VPConstraint) constraintIterator.next();
String id = constraint.getID();
String vpType = constraint.getType().getName();
Element constraintElement = new Element("vpConstraint", cmd);
constraintElement.setAttribute("id", id);
constraintElement.addContent(new Element("vpType").addContent(vpType));
vpConstraintList.addContent(constraintElement);
}
}
//��constraintModel�л�ȡ���й�ϵ
Map allPLRelation = constraintModel.getAllCFRelation();
if (allPLRelation != null) {
Iterator plRelationIterator = allPLRelation.values().iterator();
while (plRelationIterator.hasNext()) {
CFRelation plRelation = (CFRelation) plRelationIterator.next();
String id = plRelation.getID();
String constraintID = plRelation.getConstraint().getID();
String featureID = plRelation.getFeature().getID();
String isSource = Boolean.valueOf(plRelation.isSource()).toString();
String modifier = plRelation.getModifier().getName();
Element realtionElement = new Element("plRelation", cmd);
realtionElement.setAttribute("id", id);
realtionElement.addContent(new Element("constraintID").addContent(constraintID));
realtionElement.addContent(new Element("featureID").addContent(featureID));
realtionElement.addContent(new Element("isSource").addContent(isSource));
realtionElement.addContent(new Element("modifier").addContent(modifier));
relationList.addContent(realtionElement);
}
}
return doc;
}
public Document buildFmdl(FeatureModel featureModel){
//����FMDL�������ռ�
Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
Namespace fmd = Namespace.getNamespace("fmd", "http://sei.pku.edu.cn/DomainEngineering/featuremodel");
//����һ��������Ԫ��featureModel��FMDL�ĵ�
Document doc = new Document(new Element("featureModel", fmd));
//����ģ�͵�����: û����չ�����ļ���
//String fileName=file.getName();
//String featureModelName=fileName.substring(0,fileName.indexOf('.'));
//��ø�Ԫ�أ�������schemaLocation��name���ԣ����¶�FMDL�ĵ��IJ������Ը�Ԫ��Ϊ��
Element root = doc.getRootElement();
root.setAttribute("schemaLocation", "http://sei.pku.edu.cn/DomainEngineering/featuremodel featuremodel.xsd", xsi)
.setAttribute("name", featureModel.getName());
//���featureListԪ��
Element featureList = new Element("featureList", fmd);
root.addContent(featureList);
//���relationListԪ��
Element relationList = new Element("relationList", fmd);
root.addContent(relationList);
//���λ�ȡÿ���������������ԣ���FMDL�ĵ��н���featureԪ�أ��������������
//��featureModel�л�ȡ��������
Map allFeature = featureModel.getAllFeature();
if (allFeature != null) {
Iterator featureIterator = allFeature.values().iterator();
while (featureIterator.hasNext()) {
Feature feature = (Feature) featureIterator.next();
String id = feature.getID();
String name = feature.getName();
String description = feature.getDescription();
String source = feature.getSource();
String issueAndDecision = feature.getIssueAndDecision();
String note = feature.getNote();
String category = feature.getCategory().getName();
String variability = feature.getVariability().getName();
String bindingTime = feature.getBindingTime().getName();
description = _encode(description);
source = _encode(source);
issueAndDecision = _encode(issueAndDecision);
note = _encode(note);
Element featureElement = new Element("feature", fmd);
featureElement.setAttribute("id", id);
featureElement.addContent(new Element("name").addContent(name));
featureElement.addContent(new Element("description").addContent(description));
featureElement.addContent(new Element("source").addContent(source));
featureElement.addContent(new Element("category").addContent(category));
featureElement.addContent(new Element("variability").addContent(variability));
featureElement.addContent(new Element("bindingTime").addContent(bindingTime));
featureElement.addContent(new Element("issueAndDecision").addContent(issueAndDecision));
featureElement.addContent(new Element("note").addContent(note));
featureList.addContent(featureElement);
}
}
//������ļ��д洢����֮����ڵĹ�ϵ
Iterator relationNameIterator = featureModel.getAllFeatureRelationNames().iterator();
while (relationNameIterator.hasNext()) {
String relationName = (String) relationNameIterator.next();
Element relationNameElement = new Element("relation", fmd);
relationNameElement.setAttribute("name", relationName);
Iterator relationIterator = featureModel.getAllFeatureRelation(relationName).values().iterator();
while (relationIterator.hasNext()) {
FeatureRelation relation = (FeatureRelation) relationIterator.next();
Element relationElement = new Element("instance", fmd);
relationElement.setAttribute("id", relation.getID());
relationElement.addContent(new Element("startFeatureID").addContent(relation.getStartFeature().getID()));
relationElement.addContent(new Element("endFeatureID").addContent(relation.getEndFeature().getID()));
relationNameElement.addContent(relationElement);
}
relationList.addContent(relationNameElement);
}
return doc;
}
public Document buildImdl(InteractionModel interactionModel,FeatureModel featureModel){
//����IMDL�������ռ�
Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
Namespace imd = Namespace.getNamespace("cmd", "http://sei.pku.edu.cn/DomainEngineering/interactionmodel");
//����һ��������Ԫ��interactionModel��CMDL�ĵ�
Document doc = new Document(new Element("interactionModel", imd));
//��ø�Ԫ�أ�������schemaLocation��name���ԣ����¶�FMDL�ĵ��IJ������Ը�Ԫ��Ϊ��
Element root = doc.getRootElement();
root.setAttribute("schemaLocation", "http://sei.pku.edu.cn/DomainEngineering/interactionmodel interactionmodel.xsd", xsi)
.setAttribute("name", featureModel.getName());
//���resourceComponentListԪ��
Element resourceComponentList = new Element("resourceComponentList", imd);
root.addContent(resourceComponentList);
//���λ�ȡÿ���������������ԣ���IMDL�ĵ��н���resourceComponentԪ�أ��������������
Map allRC = interactionModel.getAllResourceComponent();
if (allRC != null) {
Iterator iterator = allRC.values().iterator();
while (iterator.hasNext()) {
ResourceComponent rc = (ResourceComponent) iterator.next();
String id = rc.getID();
String name = rc.getName();
String description = rc.getDescription();
String variability = rc.getVariability().getName();
String bindingTime = rc.getBindingTime().getName();
Element rcElement = new Element("resourceComponent", imd);
rcElement.setAttribute("id", id);
rcElement.addContent(new Element("name").addContent(name));
rcElement.addContent(new Element("description").addContent(description));
rcElement.addContent(new Element("variability").addContent(variability));
rcElement.addContent(new Element("bindingTime").addContent(bindingTime));
resourceComponentList.addContent(rcElement);
}
}
//���interactionListԪ��
Element interactionList = new Element("interactionList", imd);
root.addContent(interactionList);
//���λ�ȡÿ���������������ԣ���IMDL�ĵ��н���interactionԪ�أ��������������
//��interactionModel�л�ȡ����Լ��
Map allInteraction = interactionModel.getAllInteraction();
if (allInteraction != null) {
Iterator interactionIterator = allInteraction.values().iterator();
while (interactionIterator.hasNext()) {
Interaction interaction = (Interaction) interactionIterator.next();
String id = interaction.getID();
String type = interaction.getType();
String name = interaction.getName();
String activerID = interaction.getActiver().getID();
String passiverID = interaction.getPassiver().getID();
Element interactionElement = new Element("interaction", imd);
interactionElement.setAttribute("id", id);
interactionElement.setAttribute("type", type);
interactionElement.addContent(new Element("name").addContent(name));
interactionElement.addContent(new Element("activerID").addContent(activerID));
interactionElement.addContent(new Element("passiverID").addContent(passiverID));
interactionList.addContent(interactionElement);
}
}
return doc;
}
public void saveFmdl(OutputStream outStream, FeatureModel featureModel)
throws IOException, JDOMException {
Document doc = buildFmdl(featureModel);
XMLOutputter fmt = new XMLOutputter(" ", true, "GB2312");
fmt.output(doc, outStream);
}
public FComponent openFmdl(InputStream inputstream)
throws IOException, JDOMException {
ManagerInterface mi = de.FeatureModellingTool.FeatureModel.Manager.getInstance();
mi.getContext().putValue(de.FeatureModellingTool.FeatureModel.Manager.NAME_CONTEXT, " ");
mi.getContext().putValue(de.FeatureModellingTool.FeatureModel.Manager.DESCRIPTION_CONTEXT, " ");
FComponent fcomponent = null;
try {
fcomponent = (FComponent) mi.getInstance(de.FeatureModellingTool.FeatureModel.Manager.FEATURE_MODEL_NAME, FComponent.class);
} catch (IllegalParameterException ipe) {
}
/** old way
FeatureModel fm = de.FeatureModellingTool.FeatureModel.Manager.createFeatureModel(" ", " ");
FeatureModelEditor fme = de.FeatureModellingTool.FeatureModel.Manager.getFeatureModelEditor(fm);
FeatureEditor fe = de.FeatureModellingTool.FeatureModel.Manager.getFeatureEditor(fm);
FeatureModelPropertyEditor fmpe = de.FeatureModellingTool.FeatureModel.Manager.getFeatureModelPropertyEditor(fm);
**/
//new way
FeatureModel fm = (FeatureModel) fcomponent.getInterface(de.FeatureModellingTool.FeatureModel.Manager.FEATURE_MODEL_INTERFACE);
FeatureModelEditor fme = (FeatureModelEditor) fcomponent.getInterface(de.FeatureModellingTool.FeatureModel.Manager.FEATURE_MODEL_EDITOR_INTERFACE);
FeatureEditor fe = (FeatureEditor) fcomponent.getInterface(de.FeatureModellingTool.FeatureModel.Manager.FEATURE_EDITOR_INTERFACE);
FeatureModelPropertyEditor fmpe = (FeatureModelPropertyEditor) fcomponent.getInterface(de.FeatureModellingTool.FeatureModel.Manager.FEATURE_MODEL_PROPERTY_EDITOR_INTERFACE);
//
Namespace fmd = Namespace.getNamespace("fmd", "http://sei.pku.edu.cn/DomainEngineering/featuremodel");
SAXBuilder saxBuilder = new SAXBuilder(false);
Document doc = saxBuilder.build(inputstream);
Element root = doc.getRootElement();
fmpe.setName(root.getAttributeValue("name"));
//��ȡ������Ϣ
Element featureList = root.getChild("featureList", fmd);
Iterator featureIterator = featureList.getChildren("feature", fmd).iterator();
while (featureIterator.hasNext()) {
Element featureElement = (Element) featureIterator.next();
String id = featureElement.getAttributeValue("id");
String name = featureElement.getChild("name").getTextNormalize();
Feature feature = fme.addFeature(name, id);
String description = featureElement.getChild("description").getTextNormalize();
String source = featureElement.getChild("source").getTextNormalize();
String issueAndDecision = featureElement.getChild("issueAndDecision").getTextNormalize();
String note = featureElement.getChild("note").getTextNormalize();
description = _decode(description);
source = _decode(source);
issueAndDecision = _decode(issueAndDecision);
note = _decode(note);
fe.setDescription(feature,description);
fe.setSource(feature,source);
fe.setCategory(feature, FeatureCategory.getInstance(featureElement.getChild("category").getTextNormalize()));
fe.setVariability(feature, Variability.getInstance(featureElement.getChild("variability").getTextNormalize()));
fe.setBindingTime(feature, BindingTime.getInstance(featureElement.getChild("bindingTime").getTextNormalize()));
fe.setIssueAndDecision(feature,issueAndDecision);
fe.setNote(feature,note);
}
//��ȡ��ϵ��Ϣ
Element relationList = root.getChild("relationList", fmd);
Iterator relationCategoryIterator = relationList.getChildren("relation", fmd).iterator();
while (relationCategoryIterator.hasNext()) {
Element relationCategoryElement = (Element) relationCategoryIterator.next();
String relationName = relationCategoryElement.getAttributeValue("name");
Iterator relationInstanceIterator = relationCategoryElement.getChildren("instance", fmd).iterator();
while (relationInstanceIterator.hasNext()) {
Element relationInstanceElement = (Element) relationInstanceIterator.next();
String id = relationInstanceElement.getAttributeValue("id");
String startFeatureID = relationInstanceElement.getChild("startFeatureID").getTextNormalize();
String endFeatureID = relationInstanceElement.getChild("endFeatureID").getTextNormalize();
fme.addRelation(relationName, id, startFeatureID, endFeatureID);
}
}
return fcomponent;
}
public void saveCmdl(OutputStream outStream, ConstraintModel constraintModel, FeatureModel featureModel)
throws IOException, JDOMException {
Document doc = buildCmdl(constraintModel,featureModel);
XMLOutputter fmt = new XMLOutputter(" ", true, "GB2312");
fmt.output(doc, outStream);
}
public void saveImdl(OutputStream outStream, InteractionModel interactionModel, FeatureModel featureModel) throws IOException, JDOMException {
Document doc = buildImdl(interactionModel,featureModel);
XMLOutputter fmt = new XMLOutputter(" ", true, "GB2312");
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));
}
}
public void openImdl(InputStream inputstream, FComponent featureModel) throws IOException, JDOMException {
FeatureModel fm = (FeatureModel) featureModel.getInterface(de.FeatureModellingTool.FeatureModel.Manager.FEATURE_MODEL_INTERFACE);
InteractionModel im = (InteractionModel) featureModel.getInterface(de.FeatureModellingTool.FeatureModel.Manager.INTERACTION_MODEL_INTERFACE);
InteractionModelEditor ime = (InteractionModelEditor) featureModel.getInterface(de.FeatureModellingTool.FeatureModel.Manager.INTERACTION_MODEL_EDITOR_INTERFACE);
ResourceComponentEditor rce = (ResourceComponentEditor) featureModel.getInterface(de.FeatureModellingTool.FeatureModel.Manager.RESOURCE_COMPONENT_EDITOR_INTERFACE);
Namespace imd = Namespace.getNamespace("imd", "http://sei.pku.edu.cn/DomainEngineering/interactionmodel");
SAXBuilder saxBuilder = new SAXBuilder(false);
Document doc = saxBuilder.build(inputstream);
Element root = doc.getRootElement();
//��ȡ��Դ������Ϣ
Element rcList = root.getChild("resourceComponentList", imd);
if (rcList != null) {
Iterator rcIterator = rcList.getChildren("resourceComponent", imd).iterator();
while (rcIterator.hasNext()) {
Element rcElement = (Element) rcIterator.next();
String id = rcElement.getAttributeValue("id");
String name = rcElement.getChild("name").getTextNormalize();
ResourceComponent rc = ime.addResourceComponent(name, id);
rce.setDescription(rc, rcElement.getChild("description").getTextNormalize());
rce.setVariability(rc, Variability.getInstance(rcElement.getChild("variability").getTextNormalize()));
rce.setBindingTime(rc, BindingTime.getInstance(rcElement.getChild("bindingTime").getTextNormalize()));
}
}
//��ȡ������Ϣ
Element interactionList = root.getChild("interactionList", imd);
Iterator interactionIterator = interactionList.getChildren("interaction", imd).iterator();
while (interactionIterator.hasNext()) {
Element interactionElement = (Element) interactionIterator.next();
String id = interactionElement.getAttributeValue("id");
String type = interactionElement.getAttributeValue("type");
String name = interactionElement.getChild("name").getTextNormalize();
String activerID = interactionElement.getChild("activerID").getTextNormalize();
String passiverID = interactionElement.getChild("passiverID").getTextNormalize();
ime.addInteraction(id, type, name, activerID, passiverID);
}
}
//encode:��String�еĿո�,tab,���лس��滻��
protected static String _encode(String in) {
String out = in;
out = out.replaceAll("\u0020", "#x20");
out = out.replaceAll("\u0009", "#x09");
out = out.replaceAll("\n", "#x0a");
out = out.replaceAll("\r", "#x0d");
return out;
}
// decode:��ԭXML����
protected static String _decode(String in) {
String out = in;
out = out.replaceAll("#x20", "\u0020");
out = out.replaceAll("#x09", "\u0009");
out = out.replaceAll("#x0a", "\n");
out = out.replaceAll("#x0d", "\r");
return out;
}
public FComponent OpenFmdl(String fmodel) throws IOException, JDOMException {
// TODO Auto-generated method stub -- for the featuremodel from database.
return null;
}
public void saveFmdl(Writer writer, FeatureModel featureModel) throws IOException, JDOMException {
Document doc = buildFmdl(featureModel);
XMLOutputter fmt = new XMLOutputter(" ",true,"GB2312");
fmt.output(doc, writer);
}
public void saveCmdl(Writer writer, ConstraintModel cm, FeatureModel fm) throws IOException, JDOMException {
Document doc = buildCmdl(cm,fm);
XMLOutputter fmt = new XMLOutputter(" ", true, "GB2312");
fmt.output(doc,writer);
}
public void saveImdl(Writer writer , InteractionModel im , FeatureModel fm) throws IOException ,JDOMException{
Document doc = buildImdl(im,fm);
XMLOutputter fmt = new XMLOutputter(" ", true, "GB2312");
fmt.output(doc,writer);
}
}