Java Doc for FormatWriter.java in  » Swing-Library » abeille-forms-designer » org » netbeans » editor » ext » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » abeille forms designer » org.netbeans.editor.ext 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.io.Writer
      org.netbeans.editor.ext.FormatWriter

FormatWriter
final public class FormatWriter extends Writer (Code)
Formatting writter accepts the input-text, formats it and writes the output to the underlying writer. The data written to the writer are immediately splitted into token-items and the chain of token-items is created from them. Then the writer then waits for the flush() or close() method call which then makes the real formatting. The formatting is done through going through the format-layers registered in ExtFormatter and asking them for formatting. These layers go through the chain and possibly add or remove the tokens as necessary. The good thing is that the layers can ask the tokens before those written to the writer. In that case they will get the tokens from the document at point the formatting should be done. The advantage is that the chain is compact so the border between the tokens written to the writer and those that come from the document is invisible.
author:
   Miloslav Metelka
version:
   1.00

Inner Class :static class FormatTokenItem extends TokenItem.AbstractItem implements ExtTokenItem
Inner Class :static class FilterDocumentItem extends TokenItem.FilterItem implements ExtTokenItem
Inner Class :interface ExtTokenItem extends TokenItem

Field Summary
final public static  booleandebug
    
final public static  booleandebugModify
    

Constructor Summary
 FormatWriter(ExtFormatter formatter, Document doc, int offset, Writer underWriter, boolean indentOnly)
     The format writers should not be extended to enable operating of the layers on all the writers even for different languages.

Method Summary
public  booleancanInsertToken(TokenItem beforeToken)
     Check whether a new token can be inserted into the chain before the given token-item.
public  booleancanModifyToken(TokenItem token, int offset)
     Whether the token can be modified either by insertion or removal at the given offset.
public  booleancanRemoveToken(TokenItem token)
     Whether the token-item can be removed.
public  booleancanSplitEnd(TokenItem token, int endLength)
    
public  booleancanSplitStart(TokenItem token, int startLength)
    
public  StringchainToString(TokenItem token)
    
public  StringchainToString(TokenItem token, int maxDocumentTokens)
     Debug the current state of the chain.
Parameters:
  token - mark this token as current one.
public  voidcheckChain()
     Check the chain whether it's OK.
public  voidclose()
    
public  TokenItemfindFirstToken(TokenItem token)
     Find the first token in the chain.
public  TokenItemfindNonEmptyToken(TokenItem token, boolean backward)
     Check whether the given token has empty text and if so start searching for token with non-empty text in the given direction.
public  voidflush()
    
final public  DocumentgetDocument()
    
public  FormatTokenPositiongetFormatStartPosition()
     Get the first token that should be formatted.
final public  ExtFormattergetFormatter()
    
public  intgetIndentShift()
    
public  TokenItemgetLastToken()
     Get the last token in the chain.
final public  intgetOffset()
    
public  FormatTokenPositiongetPosition(TokenItem token, int offset, Position.Bias bias)
     Get the token-position that corresponds to the given offset inside the given token.
public  FormatTokenPositiongetTextStartPosition()
     Get the first position that doesn't belong to the document.
public  voidinsertString(TokenItem token, int offset, String text)
     Insert the text at the offset inside the given token.
public  TokenIteminsertToken(TokenItem beforeToken, TokenID tokenID, TokenContextPath tokenContextPath, String tokenImage)
     Create a new token-item and insert it before the token-item given as parameter.
public  booleanisAfter(TokenItem testedToken, TokenItem afterToken)
     It checks whether the tested token is after some other token in the chain.
Parameters:
  testedToken - token to test (whether it's after afterToken or not)
Parameters:
  afterToken - token to be compared to the testedToken true whether the testedToken is after afterToken or not.
public  booleanisAfter(FormatTokenPosition testedPosition, FormatTokenPosition afterPosition)
     Checks whether the tested position is after some other position.
public  booleanisChainModified()
     Return the flag that is set automatically if the new removal or insertion into chain occurs.
public  booleanisChainStartPosition(FormatTokenPosition pos)
     Check whether this is the first position in the chain of tokens.
final public  booleanisIndentOnly()
     Whether the purpose of this writer is to find the proper indentation instead of formatting the tokens.
public  booleanisRestartFormat()
     Return whether the layer requested to restart the format.
public  voidremove(TokenItem token, int offset, int length)
     Remove the length of the characters at the given offset inside the given token.
public  voidremoveToken(TokenItem token)
     Remove the token-item from the chain.
public  voidsetChainModified(boolean chainModified)
    
public  voidsetIndentOnly(boolean indentOnly)
     Sets whether the purpose of this writer is to find the proper indentation instead of formatting the tokens.
public  voidsetIndentShift(int indentShift)
    
 voidsetReformatting(boolean reformatting)
    
public  voidsetRestartFormat(boolean restartFormat)
    
public  TokenItemsplitEnd(TokenItem token, int endLength, TokenID newTokenID, TokenContextPath newTokenContextPath)
     Create the additional token from the text at the end of the given token.
public  TokenItemsplitStart(TokenItem token, int startLength, TokenID newTokenID, TokenContextPath newTokenContextPath)
     Create the additional token from the text at the start of the given token.
public  voidwrite(char[] cbuf, int off, int len)
    
public synchronized  voidwrite(char[] cbuf, int off, int len, int[] saveOffsets, Position.Bias[] saveBiases)
    

Field Detail
debug
final public static boolean debug(Code)
Whether debug messages should be displayed



debugModify
final public static boolean debugModify(Code)
Whether debug messages should be displayed




Constructor Detail
FormatWriter
FormatWriter(ExtFormatter formatter, Document doc, int offset, Writer underWriter, boolean indentOnly)(Code)
The format writers should not be extended to enable operating of the layers on all the writers even for different languages.
Parameters:
  underWriter - underlying writer




Method Detail
canInsertToken
public boolean canInsertToken(TokenItem beforeToken)(Code)
Check whether a new token can be inserted into the chain before the given token-item. The token can be inserted only into the tokens that come from the text that was written to the format-writer but was not yet written to the underlying writer.
Parameters:
  beforeToken - token-item before which the new token-item is about to beinserted. It can be null to append the new token to the end ofthe chain.



canModifyToken
public boolean canModifyToken(TokenItem token, int offset)(Code)
Whether the token can be modified either by insertion or removal at the given offset.



canRemoveToken
public boolean canRemoveToken(TokenItem token)(Code)
Whether the token-item can be removed. It can be removed only in case it doesn't come from the document's text and it wasn't yet written to the underlying writer.



canSplitEnd
public boolean canSplitEnd(TokenItem token, int endLength)(Code)



canSplitStart
public boolean canSplitStart(TokenItem token, int startLength)(Code)



chainToString
public String chainToString(TokenItem token)(Code)



chainToString
public String chainToString(TokenItem token, int maxDocumentTokens)(Code)
Debug the current state of the chain.
Parameters:
  token - mark this token as current one. It can be null.
Parameters:
  maxDocumentTokens - how many document tokens should be shown.



checkChain
public void checkChain()(Code)
Check the chain whether it's OK.



close
public void close() throws IOException(Code)



findFirstToken
public TokenItem findFirstToken(TokenItem token)(Code)
Find the first token in the chain. It should be used only when necessary and possibly in situations when the start of the chain was already reached by other methods, because this method will extend the chain till the begining of the document.
Parameters:
  token - token from which the search for previous tokens will start. Itcan be null in which case the last document token or lasttoken are attempted instead.



findNonEmptyToken
public TokenItem findNonEmptyToken(TokenItem token, boolean backward)(Code)
Check whether the given token has empty text and if so start searching for token with non-empty text in the given direction. If there's no non-empty token in the given direction the method returns null.
Parameters:
  token - token to start to search from. If it has zero length, thesearch for non-empty token is performed in the givendirection.



flush
public void flush() throws IOException(Code)



getDocument
final public Document getDocument()(Code)
Get the document being formatted



getFormatStartPosition
public FormatTokenPosition getFormatStartPosition()(Code)
Get the first token that should be formatted. This can change as the format-layers continue to change the token-chain. If the caller calls flush(), this method will return null. After additional writing to the writer, new tokens will be added and the first one of them will become the first token to be formatted. the first token that should be formatted. It can be null in casesome layer removes all the tokens that should be formatted. Mostof the layers probably do nothing in case this value is null.



getFormatter
final public ExtFormatter getFormatter()(Code)



getIndentShift
public int getIndentShift()(Code)



getLastToken
public TokenItem getLastToken()(Code)
Get the last token in the chain. It can be null if there are no tokens in the chain.



getOffset
final public int getOffset()(Code)
Get the starting offset of the formatting



getPosition
public FormatTokenPosition getPosition(TokenItem token, int offset, Position.Bias bias)(Code)
Get the token-position that corresponds to the given offset inside the given token. The returned position is persistent and if the token is removed from chain the position is assigned to the end of the previous token or to the begining of the next token if there's no previous token.
Parameters:
  token - token in which the position is created.
Parameters:
  offset - inside the token at which the position will be created.
Parameters:
  bias - forward or backward bias



getTextStartPosition
public FormatTokenPosition getTextStartPosition()(Code)
Get the first position that doesn't belong to the document. Initially it's the same as the getFormatStartPosition() but if there are multiple flushes performed on the writer they will differ.



insertString
public void insertString(TokenItem token, int offset, String text)(Code)
Insert the text at the offset inside the given token. All the token-positions at and after the offset will be increased by text.length(). IllegalArgumentException is thrown if offset is wrong.
Parameters:
  token - token in which the text is inserted.
Parameters:
  offset - offset at which the text will be inserted.
Parameters:
  text - text that will be inserted at the offset.



insertToken
public TokenItem insertToken(TokenItem beforeToken, TokenID tokenID, TokenContextPath tokenContextPath, String tokenImage)(Code)
Create a new token-item and insert it before the token-item given as parameter. The canInsertToken() should be called first to determine whether the given token can be inserted into the chain or not. The token can be inserted only into the tokens that come from the text that was written to the format-writer but was not yet written to the underlying writer.
Parameters:
  beforeToken - token-item before which the new token-item is about to beinserted. It can be null to append the new token to the end ofthe chain.
Parameters:
  tokenID - token-id of the new token-item
Parameters:
  tokenContextPath - token-context-path of the new token-item
Parameters:
  tokenImage - image of the new token-item



isAfter
public boolean isAfter(TokenItem testedToken, TokenItem afterToken)(Code)
It checks whether the tested token is after some other token in the chain.
Parameters:
  testedToken - token to test (whether it's after afterToken or not)
Parameters:
  afterToken - token to be compared to the testedToken true whether the testedToken is after afterToken or not. Returnsfalse if the token == afterToken or not or if token is before theafterToken or not.



isAfter
public boolean isAfter(FormatTokenPosition testedPosition, FormatTokenPosition afterPosition)(Code)
Checks whether the tested position is after some other position.



isChainModified
public boolean isChainModified()(Code)
Return the flag that is set automatically if the new removal or insertion into chain occurs. The formatter can use this flag to detect whether a particular format-layer changed the chain or not.



isChainStartPosition
public boolean isChainStartPosition(FormatTokenPosition pos)(Code)
Check whether this is the first position in the chain of tokens.



isIndentOnly
final public boolean isIndentOnly()(Code)
Whether the purpose of this writer is to find the proper indentation instead of formatting the tokens. It allows to have a modified formatting behavior for the cases when user presses Enter or a key that causes immediate reformatting of the line.



isRestartFormat
public boolean isRestartFormat()(Code)
Return whether the layer requested to restart the format. The formatter can use this flag to restart the formatting from the first layer.



remove
public void remove(TokenItem token, int offset, int length)(Code)
Remove the length of the characters at the given offset inside the given token. IllegalArgumentException is thrown if offset or length are wrong.
Parameters:
  token - token in which the text is removed.
Parameters:
  offset - offset at which the text will be removed.
Parameters:
  length - length of the removed text.



removeToken
public void removeToken(TokenItem token)(Code)
Remove the token-item from the chain. It can be removed only in case it doesn't come from the document's text and it wasn't yet written to the underlying writer.



setChainModified
public void setChainModified(boolean chainModified)(Code)



setIndentOnly
public void setIndentOnly(boolean indentOnly)(Code)
Sets whether the purpose of this writer is to find the proper indentation instead of formatting the tokens.
See Also:    isIndentOnly()



setIndentShift
public void setIndentShift(int indentShift)(Code)



setReformatting
void setReformatting(boolean reformatting)(Code)
Added to fix #5620



setRestartFormat
public void setRestartFormat(boolean restartFormat)(Code)



splitEnd
public TokenItem splitEnd(TokenItem token, int endLength, TokenID newTokenID, TokenContextPath newTokenContextPath)(Code)
Create the additional token from the text at the end of the given token.
Parameters:
  token - token being split.
Parameters:
  endLength - length of the text at the end of the token for which theadditional token will be created.
Parameters:
  tokenID - token-id that will be assigned to the new token
Parameters:
  tokenContextPath - token-context-path that will be assigned to the new token



splitStart
public TokenItem splitStart(TokenItem token, int startLength, TokenID newTokenID, TokenContextPath newTokenContextPath)(Code)
Create the additional token from the text at the start of the given token.
Parameters:
  token - token being split.
Parameters:
  startLength - length of the text at the begining of the token for which theadditional token will be created.
Parameters:
  tokenID - token-id that will be assigned to the new token
Parameters:
  tokenContextPath - token-context-path that will be assigned to the new token



write
public void write(char[] cbuf, int off, int len) throws IOException(Code)



write
public synchronized void write(char[] cbuf, int off, int len, int[] saveOffsets, Position.Bias[] saveBiases) throws IOException(Code)



Fields inherited from java.io.Writer
protected Object lock(Code)(Java Doc)

Methods inherited from java.io.Writer
public Writer append(CharSequence csq) throws IOException(Code)(Java Doc)
public Writer append(CharSequence csq, int start, int end) throws IOException(Code)(Java Doc)
public Writer append(char c) throws IOException(Code)(Java Doc)
abstract public void close() throws IOException(Code)(Java Doc)
abstract public void flush() throws IOException(Code)(Java Doc)
public void write(int c) throws IOException(Code)(Java Doc)
public void write(char cbuf) throws IOException(Code)(Java Doc)
abstract public void write(char cbuf, int off, int len) throws IOException(Code)(Java Doc)
public void write(String str) throws IOException(Code)(Java Doc)
public void write(String str, int off, int len) throws IOException(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.