Package de.FeatureModellingTool.PatternBase

Examples of de.FeatureModellingTool.PatternBase.PatternBaseImplementation


        fmt.output(doc, outStream);
    }

    public PatternBase openPl(InputStream inputStream, String baseType)
            throws IOException, JDOMException {
        PatternBase patternBase = new PatternBaseImplementation();
        patternBase.setBaseType(baseType);
        Namespace pbd = Namespace.getNamespace("pbd", "http://sei.pku.edu.cn/DomainEngineering/PatternBase");

        SAXBuilder saxBuilder = new SAXBuilder(false);
        Document doc = saxBuilder.build(inputStream);

        Element root = doc.getRootElement();
        patternBase.setName(root.getAttributeValue("name"));
        //�������patternʵ��
        Element patternList = root.getChild("patternList", pbd);
        Iterator patternIterator = patternList.getChildren().iterator();
        while (patternIterator.hasNext()) {
            Element patternElement = (Element) patternIterator.next();
            patternBase.addPattern(patternElement.getAttributeValue("name"));
        }
        //�������templeteʵ��
        Element templeteList = root.getChild("templeteList", pbd);
        Iterator templeteIterator = templeteList.getChildren().iterator();
        while (templeteIterator.hasNext()) {
            Element templeteElement = (Element) templeteIterator.next();
            patternBase.addTemplete(templeteElement.getAttributeValue("name"));
        }
        //Ϊ���е�ÿһ��ģʽ����������ԣ�����ģʽ��������������
        Iterator patternIteratorAgain = patternList.getChildren().iterator();

        while (patternIteratorAgain.hasNext()) {
            Element patternElement = (Element) patternIteratorAgain.next();
            Pattern pattern = patternBase.getPattern(patternElement.getAttributeValue("name"));
            String description = patternElement.getChild("description", pbd).getTextNormalize();
            description = _decode(description);
            pattern.setDescription(description);

            Element parent = patternElement.getChild("parent", pbd);
            if (parent != null) {
                Pattern parentPattern = patternBase.getPattern(parent.getAttributeValue("name"));
                pattern.setParentPattern(parentPattern);
            }

            Element childrenList = patternElement.getChild("childrenList", pbd);
            Element childrenPatternList = childrenList.getChild("childPatternList", pbd);
            Element childrenTempleteList = childrenList.getChild("childTempleteList", pbd);

            if (childrenPatternList != null) {
                Iterator childrenPatternIterator = childrenPatternList.getChildren().iterator();
                while (childrenPatternIterator.hasNext()) {
                    Element childPatternElement = (Element) childrenPatternIterator.next();
                    Pattern childPattern = patternBase.getPattern(childPatternElement.getAttributeValue("name"));
                    pattern.addChildPattern(childPattern);
                }
            }

            if (childrenTempleteList != null) {
                Iterator childrenTempleteIterator = childrenTempleteList.getChildren().iterator();
                while (childrenTempleteIterator.hasNext()) {
                    Element childTempleteElement = (Element) childrenTempleteIterator.next();
                    Templete childTemplete = patternBase.getTemplete(childTempleteElement.getAttributeValue("name"));
                    pattern.addChildTemplete(childTemplete);
                }
            }
        }

        Iterator templeteIteratorAgain = templeteList.getChildren().iterator();
        while (templeteIteratorAgain.hasNext()) {
            Element templeteElement = (Element) templeteIteratorAgain.next();
            Templete templete = patternBase.getTemplete(templeteElement.getAttributeValue("name"));

            Element parent = templeteElement.getChild("parent", pbd);
            if (parent.getAttributeValue("type") == "templete") {
                Templete parentTemplete = patternBase.getTemplete(parent.getAttributeValue("name"));
                templete.setParentTemplete(parentTemplete);
            } else {
                Pattern parentPattern = patternBase.getPattern(parent.getAttributeValue("name"));
                templete.setParentPattern(parentPattern);
            }

            Element childList = templeteElement.getChild("childTempleteList", pbd);
            if (childList != null) {
                Iterator childTempleteIterator = childList.getChildren().iterator();
                while (childTempleteIterator.hasNext()) {
                    Element childTempleteElement = (Element) childTempleteIterator.next();
                    Templete childTemplete = patternBase.getTemplete(childTempleteElement.getAttributeValue("name"));
                    templete.addChildTemplete(childTemplete);
                }
            }
        }
        return patternBase;
View Full Code Here

TOP

Related Classes of de.FeatureModellingTool.PatternBase.PatternBaseImplementation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.