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


Class ArchiveHandlerBibTeX

de.tuberlin.cs.flp.jspwiki.plugin.wikiarchive.ArchiveHandlerExternalFormatAbstract
    inheritde.tuberlin.cs.flp.jspwiki.plugin.wikiarchive.ArchiveHandlerAbstract
        inheritde.tuberlin.cs.flp.jspwiki.plugin.wikiarchive.ArchiveHandlerBibTeX

public class ArchiveHandlerBibTeX
Namespace: wikiarchive


I/O-handler for bidirectional data interchange from/to a BibTeX bibliography file.
Authors:
Jens Gulden
Version:
0.2.0


Attribute Summary
public static String  CONTENT_SUFFIX
 
public static String  CONTENT_TYPE
 
protected static Properties  DEFAULT_ENTRIES
Default BibTeX-entries to labels mapping.  
protected static Map  DEFAULT_ENTRIES_OPTIONS
Default entries to options-map mapping.  
protected static Properties  DEFAULT_FORMATS
 
protected static Properties  DEFAULT_TYPES
Default BibTeX-type to labels mapping.  
protected Properties  entries
 
protected Map  entriesOptions
 
protected Properties  formats
 
protected Properties  types
 

Method Summary
private static void  __initializer()
 
private Map   allEntries(Map m)
 
protected static void  appendToken(StreamTokenizer st, StringBuffer sb)
Appends the current token to a StringBuffer.  
protected static String   bibtexEntry(String key, Object val)
Generated a field entry string inside a BibTeX entry.  
protected static String   braceBlock(StreamTokenizer st)
Parses a block enclosed in curly braces "{" and "}". Returns the complete string inside the block. Nested curly braces are possible and will be returned as part of the string.  
protected ArchiveEntryBibTeX   convertEntry(ArchiveEntry entry)
 
public void  createEntry(Object data, ArchiveEntry entry)
Creates a new archive entry in the data source handled by this ArchiveIOHandler. @param plugin The WikiArcive plugin. 
protected String   entry2bibtex(ArchiveEntryBibTeX entry)
Generate a single BibTeX entry string.  
private static int  findNextQuoteChar(char[] c, int pos)
Finds the next occurrence of a quote char " inside a char[]-array, starting from a specified position.  
public String   getContentSuffix()
Content type for export via HTTP.  
public String   getContentType()
Content type for export via HTTP.  
public Properties   getEntries()
 
public Properties   getEntryOptions(String entryName)
 
public Properties   getFormats()
 
public Properties   getTypes()
Get BibTeX-type to labels mapping. Keys of the properties-map are BibTeX type names (values for field 'type'), values are (language-specific) label string that are used in Wiki pages.  
public void  init(WikiEngine engine, Map config)
Init.  
public boolean  isEntryOptional(String entryName)
 
public boolean  isType(String type)
 
protected static void  optional(StreamTokenizer st, char c)
Optionally allows a token to be the current token. If this token is the current one, skip to next token.  
protected Map   parseAll(Object data)
Retrieves all archive entries from the data source.  
public String   performIO(boolean io, Archive archive, Object data, int mode, Collection exceptions)
Perform either input from the Archive model interface into the data source handled by this ArchiveIOHandler. @param plugin The WikiArchive plugin. 
protected static void  putDefaults(Properties p, String[] s)
Puts an array of strings into the Properties-object, buy using each array member both as key and value for each entry. This is used for initializing dummy-properties.  
private static String   removeLineBreaksInQuotedStrings(String s)
Removes all line breaks inside quoted strings and replaces them with a single blank each. This avoids quoted multi-line-strings, which are not not supported by StreamTokenizer.  
protected void  replaceEntry(Object data, ArchiveEntry newEntryA, ArchiveEntry oldEntryA)
Replaces an archive entry in the data source handled by this ArchiveIOHandler. @param plugin The WikiArcive plugin. 
protected static void  require(StreamTokenizer st, String tok)
Tests if the tokenizer's current token matches a specified string.  
protected static void  require(StreamTokenizer st, char tok)
Tests if the tokenizer's current token matches a specified character.  
protected static void  syntax(StreamTokenizer st)
Sets the tokenizer's syntax for parsing BibTeX.  
protected String   translateKey(String key, boolean fromTo)
 
protected Map   translateKeys(Map m, boolean fromTo)
Converts the key names of Map m from/to label-strings. This uses label strings specified as parameters.  
protected String   translateType(String name, boolean fromTo)
Converts a BibTeX type name from or to its label-string. This uses label string specified as parameters.  
protected static String   until(StreamTokenizer st, char tok)
Returns all tokens until another token occurs, concatenated as one string.  

Association Summary

Own Association End Summary

Opposite Association End Summary

Tagged Values
static false
documentation#author Jens Gulden
documentation#version 0.2.0

Attribute Detail

CONTENT_SUFFIX

public static final String CONTENT_SUFFIX

Multiplicity: 1..1
Ordering: unspecified



CONTENT_TYPE

public static final String CONTENT_TYPE

Multiplicity: 1..1
Ordering: unspecified



DEFAULT_ENTRIES

protected static Properties DEFAULT_ENTRIES

Multiplicity: 1..1
Ordering: unspecified


Default BibTeX-entries to labels mapping.
Attribute Tagged Values
documentation#see #entries

See also:
#entries


DEFAULT_ENTRIES_OPTIONS

protected static Map DEFAULT_ENTRIES_OPTIONS

Multiplicity: 1..1
Ordering: unspecified


Default entries to options-map mapping.
Attribute Tagged Values
documentation#see #entriesOptions

See also:
#entriesOptions


DEFAULT_FORMATS

protected static Properties DEFAULT_FORMATS

Multiplicity: 1..1
Ordering: unspecified

Attribute Tagged Values
documentation#see #formats

See also:
#formats


DEFAULT_TYPES

protected static Properties DEFAULT_TYPES

Multiplicity: 1..1
Ordering: unspecified


Default BibTeX-type to labels mapping.
Attribute Tagged Values
documentation#see #types

See also:
#types


entries

protected Properties entries

Multiplicity: 1..1
Ordering: unspecified



entriesOptions

protected Map entriesOptions

Multiplicity: 1..1
Ordering: unspecified



formats

protected Properties formats

Multiplicity: 1..1
Ordering: unspecified



types

protected Properties types

Multiplicity: 1..1
Ordering: unspecified

Method Detail

__initializer

private static void __initializer()

Has stereotypes: << initializer >>


allEntries

private Map allEntries(Map m)

Parameters:
m -
Returns:


appendToken

protected static void appendToken(StreamTokenizer st, StringBuffer sb)


Appends the current token to a StringBuffer.
Parameters:
st - The stream tokenizer.
sb - The string buffer.


bibtexEntry

protected static String bibtexEntry(String key, Object val)


Generated a field entry string inside a BibTeX entry.
Parameters:
key - The field's name.
val - The field's value.
Returns:
field entry string


braceBlock

protected static String braceBlock(StreamTokenizer st)


Parses a block enclosed in curly braces "{" and "}". Returns the complete string inside the block. Nested curly braces are possible and will be returned as part of the string.
Method Tagged Values
documentation#throws IOException if an i/o error occurs

Parameters:
st - The stream tokenizer.
Returns:
The string enclosed in curly braces.
Exceptions:
IOException if an i/o error occurs


convertEntry

protected ArchiveEntryBibTeX convertEntry(ArchiveEntry entry)

Parameters:
entry -
Returns:


createEntry

public void createEntry(Object data, ArchiveEntry entry)


Creates a new archive entry in the data source handled by this ArchiveIOHandler. @param plugin The WikiArcive plugin.
Parameters:
data - The data source handled by this ArchiveIOHandler.
entry - The entry.


entry2bibtex

protected String entry2bibtex(ArchiveEntryBibTeX entry)


Generate a single BibTeX entry string.
Parameters:
entry - The entry to output as BibTeX.
Returns:
Single BibTeX entry.


findNextQuoteChar

private static int findNextQuoteChar(char[] c, int pos)


Finds the next occurrence of a quote char " inside a char[]-array, starting from a specified position.
Parameters:
c - The char array.
pos - The start position.
Returns:
The next index-position of a quote occurrence, or -1 if no further quotes occur.


getContentSuffix

public String getContentSuffix()


Content type for export via HTTP.
Returns:


getContentType

public String getContentType()


Content type for export via HTTP.
Returns:


getEntries

public Properties getEntries()

Returns:


getEntryOptions

public Properties getEntryOptions(String entryName)

Parameters:
entryName -
Returns:


getFormats

public Properties getFormats()

Returns:


getTypes

public Properties getTypes()


Get BibTeX-type to labels mapping. Keys of the properties-map are BibTeX type names (values for field 'type'), values are (language-specific) label string that are used in Wiki pages.
Method Tagged Values
documentation#see #types

Returns:
Properties-map with BibTeX-type to labels mapping.
See also:
#types


init

public void init(WikiEngine engine, Map config)


Init.
Parameters:
engine -
config -


isEntryOptional

public boolean isEntryOptional(String entryName)

Parameters:
entryName -
Returns:


isType

public boolean isType(String type)

Parameters:
type - The type.
Returns:


optional

protected static void optional(StreamTokenizer st, char c)


Optionally allows a token to be the current token. If this token is the current one, skip to next token.
Method Tagged Values
documentation#throws IOException if an i/o error occurs

Parameters:
st - The stream tokenizer.
c - The token that may optionally occur.
Exceptions:
IOException if an i/o error occurs


parseAll

protected Map parseAll(Object data)


Retrieves all archive entries from the data source.
Method Tagged Values
documentation#throws IOException if an i/o error occurs

Parameters:
data - The data source handled by this ArchiveIOHandler.
Returns:
Exceptions:
IOException if an i/o error occurs


performIO

public String performIO(boolean io, Archive archive, Object data, int mode, Collection exceptions)


Perform either input from the Archive model interface into the data source handled by this ArchiveIOHandler. @param plugin The WikiArchive plugin.
Method Tagged Values
documentation#throws IOException if an i/o error occurs

Parameters:
io - Switch between input or output mode, true for input into data source, false for output into Archive model interface.
archive - The Archive model interface.
data - The data source handled by this ArchiveIOHandler.
mode - The processing mode. This is a bit mask with:
bit #0 set: update exisiting entries with new values, if new data is different
bit #1 set: insert new entries
bit #2 set: ask individually for each entry (generate HTML checkbox-form first)
exceptions - Collection of entry names that should be treated as exceptions to the behaviour specified by mode. (Not used.)
Returns:
Exceptions:
IOException if an i/o error occurs


putDefaults

protected static void putDefaults(Properties p, String[] s)


Puts an array of strings into the Properties-object, buy using each array member both as key and value for each entry. This is used for initializing dummy-properties.
Parameters:
p - The properties.
s - The string array.


removeLineBreaksInQuotedStrings

private static String removeLineBreaksInQuotedStrings(String s)


Removes all line breaks inside quoted strings and replaces them with a single blank each. This avoids quoted multi-line-strings, which are not not supported by StreamTokenizer.
Parameters:
s - The string.
Returns:
String without line-breaks inside quoted parts.


replaceEntry

protected void replaceEntry(Object data, ArchiveEntry newEntryA, ArchiveEntry oldEntryA)


Replaces an archive entry in the data source handled by this ArchiveIOHandler. @param plugin The WikiArcive plugin.
Parameters:
data - The data source handled by this ArchiveIOHandler.
newEntryA - The new entry.
oldEntryA - The old entry.


require

protected static void require(StreamTokenizer st, String tok)


Tests if the tokenizer's current token matches a specified string.
Method Tagged Values
documentation#throws IOException If the token does not match.

Parameters:
st - The stream tokenizer.
tok - The token to test match with.
Exceptions:
IOException If the token does not match.


require

protected static void require(StreamTokenizer st, char tok)


Tests if the tokenizer's current token matches a specified character.
Method Tagged Values
documentation#throws IOException If the token does not match.

Parameters:
st - The stream tokenizer.
tok - The token to test match with.
Exceptions:
IOException If the token does not match.


syntax

protected static void syntax(StreamTokenizer st)


Sets the tokenizer's syntax for parsing BibTeX.
Parameters:
st - The stream tokenizer.


translateKey

protected String translateKey(String key, boolean fromTo)

Parameters:
key -
fromTo -
Returns:


translateKeys

protected Map translateKeys(Map m, boolean fromTo)


Converts the key names of Map m from/to label-strings. This uses label strings specified as parameters.
Parameters:
m - The map.
fromTo - If true, convert from label to key, if false, convert from key to label.
Returns:
Map with translated keys, same values.


translateType

protected String translateType(String name, boolean fromTo)


Converts a BibTeX type name from or to its label-string. This uses label string specified as parameters.
Method Tagged Values
documentation#see #types

Parameters:
name - The name or label.
fromTo - If true, convert from label to name, if false, convert from name to label.
Returns:
The translated string.
See also:
#types


until

protected static String until(StreamTokenizer st, char tok)


Returns all tokens until another token occurs, concatenated as one string.
Method Tagged Values
documentation#throws IOException if an i/o error occurs

Parameters:
st - The stream tokenizer.
tok - The token until which other tokens should be concatenated to the result string.
Returns:
The concatenated tokens that appeared until the specified end token was reached.
Exceptions:
IOException if an i/o error occurs
Association Detail

Opposite Association End ArchiveEntryBibTeX

public ArchiveEntryBibTeX ArchiveEntryBibTeX [1..1]



Own Association End archiveHandler

protected ArchiveHandlerBibTeX archiveHandler [1..1] navigable

Association Tagged Values
gentleware-initialValue


previous   TOC   next

Generated with Poseidon for UMLTM.
Poseidon is a registered trademark of Gentleware AG in the USA and other countries. Copyright 2003-2006 Gentleware AG, Ludwigstr. 12, 20357 Hamburg, Germany. All Rights Reserved.
UML is a trademark or registered trademark of Object Management Group, Inc. in the U.S. and other countries.