站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

AbstractGuardedSectionsProvider (Editor Guarded Sections) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.guards/0 0.1

org.netbeans.spi.editor.guards.support
Class AbstractGuardedSectionsProvider

java.lang.Object
  extended by org.netbeans.spi.editor.guards.support.AbstractGuardedSectionsProvider
All Implemented Interfaces:
GuardedSectionsProvider

public abstract class AbstractGuardedSectionsProvider
extends Object
implements GuardedSectionsProvider

The helper class that simplifies writing particular GuardedSectionsProvider implementations. Subclasses have to implement just readSections(char[]) and writeSections(java.util.List, char[]) methods.


Nested Class Summary
 class AbstractGuardedSectionsProvider.Result
           
 
Constructor Summary
protected AbstractGuardedSectionsProvider(GuardedEditorSupport editor)
           
 
Method Summary
 Reader createGuardedReader(InputStream stream, String encoding)
          Creates a reader able to read persisted sections.
 Writer createGuardedWriter(OutputStream stream, String encoding)
          Creates a writer able to write persisted sections.
 InteriorSection createInteriorSection(String name, int headerBegin, int headerEnd, int footerBegin, int footerEnd)
          Creates an interior section object to represent section read by the readSections.
 SimpleSection createSimpleSection(String name, int begin, int end)
          Creates a simple section object to represent section read by the readSections.
abstract  AbstractGuardedSectionsProvider.Result readSections(char[] content)
          This should be implemented to extract guarded sections out of the passed content.
abstract  char[] writeSections(List<GuardedSection> sections, char[] content)
          This should be implemented to persist a list of guarded sections inside the passed content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractGuardedSectionsProvider

protected AbstractGuardedSectionsProvider(GuardedEditorSupport editor)
Method Detail

createGuardedReader

public final Reader createGuardedReader(InputStream stream,
                                        String encoding)
                                 throws UnsupportedEncodingException
Description copied from interface: GuardedSectionsProvider
Creates a reader able to read persisted sections.

Specified by:
createGuardedReader in interface GuardedSectionsProvider
Parameters:
stream - stream containing persisted sections
encoding - encoding to decode read bytes
Returns:
the reader
Throws:
UnsupportedEncodingException

createGuardedWriter

public final Writer createGuardedWriter(OutputStream stream,
                                        String encoding)
                                 throws UnsupportedEncodingException
Description copied from interface: GuardedSectionsProvider
Creates a writer able to write persisted sections.

Specified by:
createGuardedWriter in interface GuardedSectionsProvider
Parameters:
stream - stream where the output should be written
encoding - encoding used by the writer
Returns:
the writer
Throws:
UnsupportedEncodingException

writeSections

public abstract char[] writeSections(List<GuardedSection> sections,
                                     char[] content)
This should be implemented to persist a list of guarded sections inside the passed content.

Parameters:
sections - guarded sections to persist
content - content
Returns:
content including guarded sections

readSections

public abstract AbstractGuardedSectionsProvider.Result readSections(char[] content)
This should be implemented to extract guarded sections out of the passed content.

Parameters:
content - content including guarded sections
Returns:
the content that will be presented to users and the list of guarded sections

createSimpleSection

public final SimpleSection createSimpleSection(String name,
                                               int begin,
                                               int end)
                                        throws BadLocationException
Creates a simple section object to represent section read by the readSections.

Parameters:
name - the section name
begin - the start offset
end - the end offset
Returns:
the simple section instance
Throws:
BadLocationException - if the given position does not represent a valid location in the associated document

createInteriorSection

public final InteriorSection createInteriorSection(String name,
                                                   int headerBegin,
                                                   int headerEnd,
                                                   int footerBegin,
                                                   int footerEnd)
                                            throws BadLocationException
Creates an interior section object to represent section read by the readSections.

Parameters:
name - the section name
headerBegin - begin the start offset of the first guarded part
headerEnd - end the end offset of the first guarded part
footerBegin - begin the start offset of the second guarded part
footerEnd - end the end offset of the second guarded part
Returns:
the interior section object
Throws:
BadLocationException - if the given position does not represent a valid location in the associated document

org.netbeans.modules.editor.guards/0 0.1

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.