Package com.tagtraum.core.json
Class LibraryJSONContentHandler
- java.lang.Object
-
- com.tagtraum.core.json.JSONContentHandler
-
- com.tagtraum.core.json.LibraryJSONContentHandler
-
- All Implemented Interfaces:
org.json.simple.parser.ContentHandler
public class LibraryJSONContentHandler extends JSONContentHandler
A content handler for stream processing of JSON describing a media library. Individual items (songs) may be processed usingItemProcessor
s.- Author:
- Hendrik Schreiber
- See Also:
addItemProcessor(ItemProcessor)
-
-
Field Summary
Fields Modifier and Type Field Description static String
KEY_ITEMS
static String
KEY_LIBRARY
static String
KEY_LISTS
static String
KEY_USER
-
Fields inherited from class com.tagtraum.core.json.JSONContentHandler
LONG_CACHE
-
-
Constructor Summary
Constructors Constructor Description LibraryJSONContentHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addItemProcessor(ItemProcessor processor)
void
addListProcessor(ItemProcessor processor)
boolean
addObjectToContainer(Object object)
Overwrite this method to prevent an object to be added to its surrounding container.void
endLibraryItems()
void
endLibraryLists()
boolean
endObjectEntry()
List<ItemProcessor>
getItemProcessors()
Map<String,Object>
getLibrary()
List<ItemProcessor>
getListProcessors()
Long
getRemoteLibraryId()
Remote library id, if available.boolean
processItem(Object object)
Overwrite this method to process specific objects.void
startLibraryItems()
void
startLibraryLists()
boolean
startObjectEntry(String key)
-
Methods inherited from class com.tagtraum.core.json.JSONContentHandler
endArray, endJSON, endObject, getRoot, getStack, primitive, startArray, startJSON, startObject
-
-
-
-
Field Detail
-
KEY_ITEMS
public static final String KEY_ITEMS
- See Also:
- Constant Field Values
-
KEY_LIBRARY
public static final String KEY_LIBRARY
- See Also:
- Constant Field Values
-
KEY_USER
public static final String KEY_USER
- See Also:
- Constant Field Values
-
KEY_LISTS
public static final String KEY_LISTS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getItemProcessors
public List<ItemProcessor> getItemProcessors()
-
addItemProcessor
public void addItemProcessor(ItemProcessor processor)
-
getListProcessors
public List<ItemProcessor> getListProcessors()
-
addListProcessor
public void addListProcessor(ItemProcessor processor)
-
getRemoteLibraryId
public Long getRemoteLibraryId()
Remote library id, if available.- Returns:
- library id
-
startObjectEntry
public boolean startObjectEntry(String key) throws org.json.simple.parser.ParseException, IOException
- Specified by:
startObjectEntry
in interfaceorg.json.simple.parser.ContentHandler
- Overrides:
startObjectEntry
in classJSONContentHandler
- Throws:
org.json.simple.parser.ParseException
IOException
-
endObjectEntry
public boolean endObjectEntry() throws org.json.simple.parser.ParseException, IOException
- Specified by:
endObjectEntry
in interfaceorg.json.simple.parser.ContentHandler
- Overrides:
endObjectEntry
in classJSONContentHandler
- Throws:
org.json.simple.parser.ParseException
IOException
-
endLibraryItems
public void endLibraryItems()
-
startLibraryItems
public void startLibraryItems()
-
endLibraryLists
public void endLibraryLists()
-
startLibraryLists
public void startLibraryLists()
-
processItem
public boolean processItem(Object object)
Description copied from class:JSONContentHandler
Overwrite this method to process specific objects.- Overrides:
processItem
in classJSONContentHandler
- Parameters:
object
- object- Returns:
- false to abort further processing
-
addObjectToContainer
public boolean addObjectToContainer(Object object)
Description copied from class:JSONContentHandler
Overwrite this method to prevent an object to be added to its surrounding container. This can be useful for inline processing to preserve memory.- Overrides:
addObjectToContainer
in classJSONContentHandler
- Parameters:
object
- object- Returns:
- false, if the given object should be added to the surrounding container.
-
-