public final class GuardedSectionManager extends Object
Modifier and Type | Method and Description |
---|---|
InteriorSection |
createInteriorSection(Position pos,
String name)
Creates an empty interior section at the given position.
|
SimpleSection |
createSimpleSection(Position pos,
String name)
Creates an empty simple section at the given position.
|
InteriorSection |
findInteriorSection(String name)
Tries to find the interior section of the given name.
|
SimpleSection |
findSimpleSection(String name)
Tries to find the simple section of the given name.
|
Iterable<GuardedSection> |
getGuardedSections()
Gets all sections.
|
static GuardedSectionManager |
getInstance(StyledDocument doc)
Gets the manager instance.
|
SimpleSection |
protectSimpleRegion(Position start,
Position end,
String name)
Creates a simple section from a region of code.
|
public static GuardedSectionManager getInstance(StyledDocument doc)
doc
- a document containing guarded sectionsnull
.public SimpleSection findSimpleSection(String name)
name
- the name of the requested sectionnull
if there is no section
of the given namepublic InteriorSection findInteriorSection(String name)
name
- the name of the looked-for sectionnull
if there is no section
of the given namepublic SimpleSection createSimpleSection(Position pos, String name) throws IllegalArgumentException, BadLocationException
IllegalArgumentException
- if either the name has been already used, or
the position is inside another section or Java Element.BadLocationException
- if pos is outside of document's scope, or
the document does not permit creating the guarded section.public SimpleSection protectSimpleRegion(Position start, Position end, String name) throws IllegalArgumentException, BadLocationException
GuardedSectionManager.createSimpleSection(javax.swing.text.Position, java.lang.String)
, this method is
intended for marking existing text protected/guarded.
Use GuardedSection.removeSection()
to remove the protection.
start
- start of the protected textend
- end of text, exclusive.name
- name for the guarded sectionIllegalArgumentException
BadLocationException
public InteriorSection createInteriorSection(Position pos, String name) throws IllegalArgumentException, BadLocationException
IllegalArgumentException
- if either the name has been already used, or
the position is inside another section or Java Element.BadLocationException
- if pos is outside of document's scope, or
the document does not permit creating the guarded section.public Iterable<GuardedSection> getGuardedSections()
GuardedSection
s