Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: javax/ide/model/spi/XMLRootElementRecognizer.java


1   package javax.ide.model.spi;
2   
3   import java.util.Collection;
4   import java.util.Collections;
5   import java.util.HashSet;
6   import javax.ide.extension.ElementName;
7   import javax.ide.util.MetaClass;
8   
9   /**
10   * Information about how to recognize an XML document by its root element.
11   */
12  public final class XMLRootElementRecognizer extends SuffixRecognizer
13  {
14    private Collection _rootElements = new HashSet();
15    
16    public XMLRootElementRecognizer( MetaClass documentClass )
17    {
18      super( documentClass );    
19    }
20    
21    public void addRootElement( ElementName elementName )
22    {
23      _rootElements.add( elementName );
24    }
25    
26    public Collection getSuffixes()
27    {
28      Collection suffixes = super.getSuffixes();
29      if ( suffixes.isEmpty() )
30      {
31        return Collections.singleton( ".xml" );
32      }
33      return suffixes;
34    }
35    
36    public Collection getRootElements()
37    {
38      return Collections.unmodifiableCollection( _rootElements );
39    }
40  }