de.tuberlin.cs.flp.jspwiki.plugin.wikiarchive
Class ArchiveHandlerWiki

java.lang.Object
  extended byde.tuberlin.cs.flp.jspwiki.plugin.wikiarchive.ArchiveHandlerAbstract
      extended byde.tuberlin.cs.flp.jspwiki.plugin.wikiarchive.ArchiveHandlerWiki
All Implemented Interfaces:
ArchiveHandler

public class ArchiveHandlerWiki
extends ArchiveHandlerAbstract

I/O-handler for bidirectional data interchange from/to Wiki pages. This is the 'internal' i/o-handler of the Bibliography Wiki-archive.


Nested Class Summary
 class ArchiveHandlerWiki.WikiDataSource
          Inner class.
 
Field Summary
protected  java.lang.String categoryMarker
           
 
Fields inherited from class de.tuberlin.cs.flp.jspwiki.plugin.wikiarchive.ArchiveHandlerAbstract
config, engine
 
Fields inherited from interface de.tuberlin.cs.flp.jspwiki.plugin.wikiarchive.ArchiveHandler
EXPORT, IMPORT
 
Constructor Summary
ArchiveHandlerWiki(java.lang.String categoryMarker)
           
 
Method Summary
 java.lang.Object createData()
          Creates an empty data source to be filled for export.
protected  void createEntry(java.lang.Object data, ArchiveEntry entry)
          Creates a new archive entry in the data source handled by this ArchiveIOHandler.
 java.lang.String dataToString(java.lang.Object data)
          Converts the handled data source to string for export.
protected static java.lang.String entry2wiki(ArchiveEntry entry, java.lang.String categoryMarker, boolean useOutgoingLinks)
           
 java.lang.String getContentSuffix()
          Content type for export via HTTP.
 java.lang.String getContentType()
          Content type for export via HTTP.
protected static java.lang.String getNormalPageText(java.lang.String s)
          Returns all normal text in a wiki page, i.e.
protected  java.lang.String msgDone(ArchiveEntry inEntry, ArchiveEntry outEntry, int mode)
          Outputs a message informing about the action that has been taken for an entry.
protected  java.lang.String msgNotDone(ArchiveEntry inEntry, ArchiveEntry outEntry, int mode)
          Outputs a message informing that an action has not been taken for an entry.
protected  java.lang.String msgToDo(ArchiveEntry inEntry, ArchiveEntry outEntry, int mode)
          Outputs a message informing about the possible action to be taken for an input entry, e.g.
protected  java.util.Map parseAll(java.lang.Object data)
          Retrieves all archive entries from the data source.
protected static java.util.Map parseWikiTableAsMap(java.lang.String s)
          Parses entries of a Wiki table as a key/value-map.
protected  void replaceEntry(java.lang.Object data, ArchiveEntry newEntry, ArchiveEntry oldEntry)
          Replaces an archive entry in the data source handled by this ArchiveIOHandler.
 void stringToData(java.lang.String s, java.lang.Object data)
          Converts a string to a handled data source for import.
static ArchiveEntry wiki2entry(java.lang.String pagename, java.lang.String pagedata, java.lang.String categoryMarker)
          Converts Wiki-markup of a bibliography entry page in the Wiki to a ArchiveEntryBibTeX.
 
Methods inherited from class de.tuberlin.cs.flp.jspwiki.plugin.wikiarchive.ArchiveHandlerAbstract
equalEntries, getEngine, init, performIO, setEngine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

categoryMarker

protected java.lang.String categoryMarker
Constructor Detail

ArchiveHandlerWiki

public ArchiveHandlerWiki(java.lang.String categoryMarker)
Parameters:
categoryMarker -
Method Detail

createData

public java.lang.Object createData()
Creates an empty data source to be filled for export.

Specified by:
createData in interface ArchiveHandler
Specified by:
createData in class ArchiveHandlerAbstract
Returns:

dataToString

public java.lang.String dataToString(java.lang.Object data)
Converts the handled data source to string for export.

Specified by:
dataToString in interface ArchiveHandler
Overrides:
dataToString in class ArchiveHandlerAbstract
Parameters:
data -
Returns:

stringToData

public void stringToData(java.lang.String s,
                         java.lang.Object data)
Converts a string to a handled data source for import.

Specified by:
stringToData in interface ArchiveHandler
Overrides:
stringToData in class ArchiveHandlerAbstract
Parameters:
s -
data -

getContentType

public java.lang.String getContentType()
Content type for export via HTTP.

Specified by:
getContentType in interface ArchiveHandler
Specified by:
getContentType in class ArchiveHandlerAbstract
Returns:

getContentSuffix

public java.lang.String getContentSuffix()
Content type for export via HTTP.

Specified by:
getContentSuffix in interface ArchiveHandler
Specified by:
getContentSuffix in class ArchiveHandlerAbstract
Returns:

parseAll

protected java.util.Map parseAll(java.lang.Object data)
Retrieves all archive entries from the data source. ("Parse" is not the best chosen term in this method's name, although in some cases it may perform parsing if the data source is a string.)

Specified by:
parseAll in class ArchiveHandlerAbstract
Parameters:
data - The data source handled by this ArchiveIOHandler.
Returns:

createEntry

protected void createEntry(java.lang.Object data,
                           ArchiveEntry entry)
                    throws java.io.IOException
Creates a new archive entry in the data source handled by this ArchiveIOHandler.

Specified by:
createEntry in class ArchiveHandlerAbstract
Parameters:
data - The data source handled by this ArchiveIOHandler.
entry - The entry.
Throws:
java.io.IOException - if an i/o error occurs

replaceEntry

protected void replaceEntry(java.lang.Object data,
                            ArchiveEntry newEntry,
                            ArchiveEntry oldEntry)
                     throws java.io.IOException
Replaces an archive entry in the data source handled by this ArchiveIOHandler.

Specified by:
replaceEntry in class ArchiveHandlerAbstract
Parameters:
data - The data source handled by this ArchiveIOHandler.
newEntry - The new entry.
oldEntry - The old entry.
Throws:
java.io.IOException - if an i/o error occurs

msgToDo

protected java.lang.String msgToDo(ArchiveEntry inEntry,
                                   ArchiveEntry outEntry,
                                   int mode)
Outputs a message informing about the possible action to be taken for an input entry, e.g. whether it would be added as a new entry, or an existing one would be updated.

Specified by:
msgToDo in class ArchiveHandlerAbstract
Parameters:
inEntry - The input entry.
outEntry - The currently existing possible output entry, or null if such does not exist yet.
mode - The action mode, like the mode parameter of performIO().
Returns:
The message string. (Actually used to build a part of an HTML-form user interface.)

msgDone

protected java.lang.String msgDone(ArchiveEntry inEntry,
                                   ArchiveEntry outEntry,
                                   int mode)
Outputs a message informing about the action that has been taken for an entry.

Specified by:
msgDone in class ArchiveHandlerAbstract
Parameters:
inEntry - The entry processed.
outEntry - The currently existing possible output entry, or null if such does not exist yet.
mode - The action mode, like the mode parameter of performIO().
Returns:
The message string. (Actually used to build a part of an HTML-form user interface.)

msgNotDone

protected java.lang.String msgNotDone(ArchiveEntry inEntry,
                                      ArchiveEntry outEntry,
                                      int mode)
Outputs a message informing that an action has not been taken for an entry.

Specified by:
msgNotDone in class ArchiveHandlerAbstract
Parameters:
inEntry - The entry not processed.
outEntry - The currently existing possible output entry, or null if such does not exist yet.
mode - The action mode, like the mode parameter of performIO().
Returns:
The message string. (Actually used to build a part of an HTML-form user interface.)

wiki2entry

public static ArchiveEntry wiki2entry(java.lang.String pagename,
                                      java.lang.String pagedata,
                                      java.lang.String categoryMarker)
Converts Wiki-markup of a bibliography entry page in the Wiki to a ArchiveEntryBibTeX.

Parameters:
pagename - Name of a Wiki page representing a bibliography entry.
pagedata - The page's Wiki-markup.
categoryMarker -
Returns:
ArchiveEntryBibTeX parsed from the Wiki-page's table entries.
See Also:
#bib2wiki(ArchiveEntryBibTeX)

entry2wiki

protected static java.lang.String entry2wiki(ArchiveEntry entry,
                                             java.lang.String categoryMarker,
                                             boolean useOutgoingLinks)
Parameters:
entry -
categoryMarker -
useOutgoingLinks -
Returns:

parseWikiTableAsMap

protected static java.util.Map parseWikiTableAsMap(java.lang.String s)
Parses entries of a Wiki table as a key/value-map. The specified string gets scanned for Wiki-table markup (using '|' as marker), each first column of a table is considered to contain key values, each second column is taken as source for an entry-value. Other columns are not used.

Parameters:
s - Wiki-text with table markup.
Returns:
Map wih parsed key/value-pairs.
See Also:
#bib2wiki(BibEntry)

getNormalPageText

protected static java.lang.String getNormalPageText(java.lang.String s)
Returns all normal text in a wiki page, i.e. all text that is not part of a table.

Parameters:
s -
Returns: