Ejemplo n.º 1
0
 @Nullable
 public static Configuration load(final InputStream is) throws IOException, JDOMException {
   try {
     final Document document = JDOMUtil.loadDocument(is);
     final ArrayList<Element> elements = new ArrayList<Element>();
     final Element rootElement = document.getRootElement();
     final Element state;
     if (rootElement.getName().equals(COMPONENT_NAME)) {
       state = rootElement;
     } else {
       elements.add(rootElement);
       //noinspection unchecked
       elements.addAll(rootElement.getChildren("component"));
       state =
           ContainerUtil.find(
               elements,
               new Condition<Element>() {
                 public boolean value(final Element element) {
                   return "component".equals(element.getName())
                       && COMPONENT_NAME.equals(element.getAttributeValue("name"));
                 }
               });
     }
     if (state != null) {
       final Configuration cfg = new Configuration();
       cfg.loadState(state);
       return cfg;
     }
     return null;
   } finally {
     is.close();
   }
 }
Ejemplo n.º 2
0
 @Override
 public void loadState(final Element element) {
   myAdvancedConfiguration.loadState(element);
   super.loadState(element);
 }