public class ObjectLinker
extends java.lang.Object
ObjectLinker creates and holds an object oriented database. So we get an abstraction to collada XML structure. ObjectLinker get its instructions via <loading> section in linking schema.
In natural order and for each <entities> tag a new scan via SaxParser starts again committing search patterns. Each returned "SaxParser.Record" objects is added into DB tables and linked/backlinked to other Records (see also linking schema specifications <target>).
Following fields into "SaxParser.Record" is added by ObjectLinker:
The database has the format:
HashMap<poolname,TreeMap<uniqueID,recordObject>>
resp.
HashMap<String,TreeMap<String,SaxParser.Record>>
Note: If the natural order of Records matters let ObjectLinker generate an uniqueID and limit to 2'147'483'647 entities per pool name
this class has a main() method to test a sketchup Version 8 dae file with colors and texture. It depends on xmlfiles SaxParser SimpleDomParser and Log
This source is free; you can redistribute it and/or modify it under the terms of the GNU General Public License and by nameing of the originally author
| Modifier and Type | Class and Description |
|---|---|
class |
ObjectLinker.CTXInfo
Wrapps all infos needed to build the internal database
This fields is set BEFORE object linker does his work
|
class |
ObjectLinker.RecInfo
this class wrapps individual infos for each DB record
this fields is set AFTER ObjectLinker is done
|
| Modifier and Type | Field and Description |
|---|---|
private java.util.HashMap<java.lang.String,java.util.TreeMap<java.lang.String,SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>>> |
database |
private int |
IdCnt |
| Constructor and Description |
|---|
ObjectLinker() |
| Modifier and Type | Method and Description |
|---|---|
private void |
execJobs(java.util.List<SimpleDomParser.Element> entities,
java.lang.String daeFile,
SaxParser<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> sax)
Iterates all jobs in <entities> and rescans
the whole .dae document each time
|
java.util.HashMap<java.lang.String,java.util.TreeMap<java.lang.String,SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>>> |
getDatabase()
See notes on the class description
|
private java.lang.String |
getValue(java.lang.String expression,
SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> r)
Returns a Textcontent or an attribute value from
record, depending on the expression.
|
private java.util.List<SimpleDomParser.Element> |
initLoadingJobs(java.lang.String filename)
parses linking schema.
|
private SaxParser<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> |
initSaxParser()
creates a sax parser that scans a later defined
collada file.
|
private java.util.List<SaxParser.Context<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>> |
initSearchPatterns(SimpleDomParser.Element aTarget,
SaxParser.Context<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> parent,
java.lang.String poolname)
Digs recursively into <target> tag and its
subtags in linking schema to get all search
patterns for SaxParser class
|
private SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> |
linkRecord(SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> aDaeRec,
SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> parentRec,
SaxParser.Context<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> ctx)
Adds a RecInfo(), gives a unique ID (or defined ID by collada)
establish foreign key links/backlinks and does the same
procedure with its children recursively
|
void |
start(java.lang.String filename,
java.lang.String daeFile)
The schemaFile says how to parse a .dae file into a
valid internal database using searchpatterns to
fetch collada xml tags, or linking instructions
|
private java.util.HashMap<java.lang.String,java.util.TreeMap<java.lang.String,SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>>> database
private int IdCnt
private java.util.List<SimpleDomParser.Element> initLoadingJobs(java.lang.String filename) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
linking - schemajava.io.IOExceptionorg.xml.sax.SAXExceptionjavax.xml.parsers.ParserConfigurationExceptionprivate SaxParser<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> initSaxParser()
private void execJobs(java.util.List<SimpleDomParser.Element> entities, java.lang.String daeFile, SaxParser<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> sax) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
entities - daeFile - sax - javax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXExceptionjava.io.IOExceptionpublic void start(java.lang.String filename,
java.lang.String daeFile)
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException,
java.io.IOException
schemaFile - with focus to "entities" tagscollada - filejava.io.IOExceptionorg.xml.sax.SAXExceptionjavax.xml.parsers.ParserConfigurationExceptionprivate java.util.List<SaxParser.Context<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>> initSearchPatterns(SimpleDomParser.Element aTarget, SaxParser.Context<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> parent, java.lang.String poolname)
aTarget - parent - or null if root <target>private SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> linkRecord(SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> aDaeRec, SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> parentRec, SaxParser.Context<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> ctx)
aDaeRec - parentRec - ctx - private java.lang.String getValue(java.lang.String expression,
SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo> r)
expression - 'myValue' or '#myAttributeName' or '$TEXTCONTENT' or nullr - current record (child or parent)public java.util.HashMap<java.lang.String,java.util.TreeMap<java.lang.String,SaxParser.Record<ObjectLinker.CTXInfo,ObjectLinker.RecInfo>>> getDatabase()