org.netbeans.modules.parsing.api/1 1.55.0 6

org.netbeans.modules.parsing.spi
Class ParserFactory

java.lang.Object
  extended by org.netbeans.modules.parsing.spi.ParserFactory

public abstract class ParserFactory
extends Object

The factory for Parsers. ParserFactory implemementations can be registered in MimeLoolup either for a specific mime type or for all languages. The example below shows ParserFactory registration for text/x-something mime type in an XML layer.

 <folder name="Editors">
  <folder name="text">
   <folder name="x-something">
    <file name="org-some-module-MyParserFactory.instance" />
   </folder>
  </folder>
 </folder>
 


Constructor Summary
ParserFactory()
           
 
Method Summary
abstract  Parser createParser(Collection<Snapshot> snapshots)
          Creates a new instance of Parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParserFactory

public ParserFactory()
Method Detail

createParser

public abstract Parser createParser(Collection<Snapshot> snapshots)
Creates a new instance of Parser. In general parsers are created for either one or several snapshots (ie. document sections), which are provided to this method. It is guaranteed that all snapshots in the collection will be of the same mime type and it will be the mime type, which this factory was registered for (ie. in MimeLookup). Typical factories won't need the snapshots for creating a parser, but factories that serve multiple languages (eg. in GSF or other language support frameworks) may find this useful.

It is important to remember that the snapshots are provided only for the factory and they reflect document states at the time when the factory is called. Since the parsing infrastructure may cache parser instances it will provide a new snapshot when it asks Parsers to do their job. Therefore the snapshots here may only be used for the parser creation, but must never be used for parsing!

Parameters:
snapshots - Snaphots of documents, which the new parser will be asked to parse.
Returns:
The new Parser instance or null if this factory does not have a parser suitable for parsing this type of snapshots.

org.netbeans.modules.parsing.api/1 1.55.0 6

Built on May 24 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.