View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.support.messagebox.parser;
17  
18  import org.seamless.xml.DOMElement;
19  import org.w3c.dom.Element;
20  
21  import javax.xml.xpath.XPath;
22  
23  /**
24   * @author Christian Bauer
25   */
26  public class MessageElement extends DOMElement<MessageElement, MessageElement> {
27  
28      public static final String XPATH_PREFIX = "m";
29  
30      public MessageElement(XPath xpath, Element element) {
31          super(xpath, element);
32      }
33  
34      @Override
35      protected String prefix(String localName) {
36          return XPATH_PREFIX + ":" + localName;
37      }
38  
39      @Override
40      protected Builder<MessageElement> createParentBuilder(DOMElement el) {
41          return new Builder<MessageElement>(el) {
42              @Override
43              public MessageElement build(Element element) {
44                  return new MessageElement(getXpath(), element);
45              }
46          };
47      }
48  
49      @Override
50      protected ArrayBuilder<MessageElement> createChildBuilder(DOMElement el) {
51          return new ArrayBuilder<MessageElement>(el) {
52              @Override
53              public MessageElement[] newChildrenArray(int length) {
54                  return new MessageElement[length];
55              }
56  
57              @Override
58              public MessageElement build(Element element) {
59                  return new MessageElement(getXpath(), element);
60              }
61          };
62      }
63  
64  }