org.topbraid.spreadsheets.util
Class SpreadsheetUtil

java.lang.Object
  extended by org.topbraid.spreadsheets.util.SpreadsheetUtil
All Implemented Interfaces:
IMapConstants
Direct Known Subclasses:
AbstractMapEngine

public class SpreadsheetUtil
extends java.lang.Object
implements IMapConstants


Field Summary
static java.lang.String HASH
           
 
Fields inherited from interface org.topbraid.spreadsheets.IMapConstants
CELL, CLASSSEPARATOR, COLUMN, COMMA, EMPTY, NULLRESOURCE, OBJECT, PREDICATE, QUOTE, RESOURCE, ROW, SUBJECT
 
Constructor Summary
SpreadsheetUtil()
           
 
Method Summary
static void addProperty(com.hp.hpl.jena.rdf.model.Resource resource, com.hp.hpl.jena.rdf.model.Property property, java.lang.String lexicalValue)
           
static void addProperty(com.hp.hpl.jena.rdf.model.Resource resource, com.hp.hpl.jena.rdf.model.Property property, java.lang.String lexicalValue, com.hp.hpl.jena.datatypes.RDFDatatype rdfDatatype)
           
static java.lang.String[] getClassNames(Spreadsheet spreadsheet, com.hp.hpl.jena.rdf.model.Resource config)
           
static java.lang.String[] getCommasplitItems(java.lang.String source, com.hp.hpl.jena.rdf.model.Resource config, java.util.Set ignoreListSpecialCheck)
           
static java.io.File getExistingFile(java.lang.String fileName)
           
static java.lang.Object getExistingFileSource(java.lang.String fileName)
           
static org.eclipse.core.resources.IFile getExistingResource(java.lang.String fileName)
           
static java.net.URL getExistingURL(java.lang.String fileName)
           
static java.lang.String getImportMessage(com.hp.hpl.jena.rdf.model.Resource config)
           
static java.lang.String getInverse(java.lang.Object input)
          Get the inverse of COLUMN / ROW
static java.lang.Object getInverse(java.lang.Object input, java.lang.Object first, java.lang.Object second)
          Get the inverse identifier.
static java.lang.String getItem(java.lang.String source, com.hp.hpl.jena.rdf.model.Resource config)
           
static void getItem(java.lang.String source, java.lang.StringBuffer result, java.lang.String localName, com.hp.hpl.jena.rdf.model.Resource config)
           
static void getItem(java.lang.String source, java.lang.StringBuffer result, java.lang.String localName, com.hp.hpl.jena.rdf.model.Resource config, java.util.Set ignoreSpecialCheck)
           
static java.lang.String getItem(java.lang.String source, java.lang.String localName, com.hp.hpl.jena.rdf.model.Resource config)
           
static java.lang.String getItem(java.lang.String source, java.lang.String localName, com.hp.hpl.jena.rdf.model.Resource config, java.util.Set ignoreSpecialCheck)
           
static java.lang.String[] getItems(java.lang.String source, java.lang.String splitter, java.lang.String surrounder, com.hp.hpl.jena.rdf.model.Resource config)
           
static java.lang.String[] getItems(java.lang.String source, java.lang.String splitter, java.lang.String surrounder, com.hp.hpl.jena.rdf.model.Resource config, java.util.Set ignoreSpecialCheck)
           
static java.lang.String[] getItems(java.lang.String source, java.lang.String localName, java.lang.String splitter, java.lang.String surrounder, com.hp.hpl.jena.rdf.model.Resource config, java.util.Set ignoreSpecialCheck)
           
static java.util.List<java.lang.String> getOrderedPropertyColumns(java.lang.String[] colNames, com.hp.hpl.jena.rdf.model.Resource config)
           
static java.util.List<java.lang.String> getOrderedPropertyColumns(java.lang.String[] colNames, java.lang.String idPattern)
           
static com.hp.hpl.jena.rdf.model.Resource getPropertyDetails(java.lang.String colName, com.hp.hpl.jena.rdf.model.Resource config)
           
static com.hp.hpl.jena.rdf.model.Resource getResource(com.hp.hpl.jena.rdf.model.Model model, java.lang.String rawLabel)
           
static com.hp.hpl.jena.rdf.model.Resource getResource(com.hp.hpl.jena.rdf.model.Model model, java.lang.String rawLabel, com.hp.hpl.jena.rdf.model.Resource config)
          Gets a resource already existing in the model.
static org.eclipse.core.resources.IFile getResource(java.lang.String fileLocation)
           
static com.hp.hpl.jena.rdf.model.Resource getResourceByName(com.hp.hpl.jena.rdf.model.Model model, java.lang.String qName)
          Deprecated. - will be moved to Labels.java
static java.lang.String getSchema(java.lang.String uri)
           
static java.util.Set getSetElement(java.util.Map map, java.lang.Object key)
           
static Spreadsheet getSpreadsheetFromSource(java.lang.Object fileSource)
           
static Spreadsheet getSpreedsheetFromURL(java.lang.String url)
           
static void getTypesOfLabel(java.util.List<java.lang.Object> classes, java.lang.String rowHead, com.hp.hpl.jena.rdf.model.Model model, com.hp.hpl.jena.rdf.model.Resource config)
           
static java.lang.String getUnsurroundedString(java.lang.String sourceStr, java.lang.String surroundStr)
           
static java.lang.String getURIFlex(com.hp.hpl.jena.rdf.model.Model model, java.lang.String qName)
          Deprecated. - will be moved to Labels.java
static void guessClass(Spreadsheet spreadsheet, com.hp.hpl.jena.rdf.model.Model model, int maxAllowed, java.lang.String[] classNames, java.util.List<java.util.List> returnList, com.hp.hpl.jena.rdf.model.Resource config, int position, java.lang.String location)
           
static java.util.List[] guessClass(Spreadsheet spreadsheet, com.hp.hpl.jena.rdf.model.Resource config, com.hp.hpl.jena.rdf.model.Model model, int maxAllowed)
           
static java.util.List guessClass(Spreadsheet ss, java.lang.String position, com.hp.hpl.jena.rdf.model.Model model, com.hp.hpl.jena.rdf.model.Resource config, int maxAllowed)
           
static boolean isColumnNameChecked(java.lang.String colName, com.hp.hpl.jena.rdf.model.Resource config)
           
static boolean isSpreadsheetEmpty(Spreadsheet spreadsheet)
           
static boolean isSurroundedWith(java.lang.String sourceStr, java.lang.String surroundStr)
           
static java.lang.Object mapObject(com.hp.hpl.jena.rdf.model.Model model, java.lang.String rawLabel, com.hp.hpl.jena.rdf.model.Resource subject, com.hp.hpl.jena.rdf.model.Resource predicate, com.hp.hpl.jena.rdf.model.Resource config)
           
static com.hp.hpl.jena.rdf.model.Resource mapResource(com.hp.hpl.jena.rdf.model.Model model, java.lang.String rawLabel)
           
static com.hp.hpl.jena.rdf.model.Resource mapResource(com.hp.hpl.jena.rdf.model.Model model, java.lang.String rawLabel, com.hp.hpl.jena.rdf.model.Resource config)
          Maps the rawLabel to a resource in model.
static java.lang.String parseLiteral(java.lang.String source)
           
static boolean putSetElement(java.util.Map<java.lang.Object,java.util.Set> map, java.lang.Object key, java.lang.Object value)
           
static java.lang.String unionURIs(java.lang.String uri1, java.lang.String uri2)
          Generates a URI with a union of the general and local parts of the URI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HASH

public static final java.lang.String HASH
See Also:
Constant Field Values
Constructor Detail

SpreadsheetUtil

public SpreadsheetUtil()
Method Detail

getClassNames

public static java.lang.String[] getClassNames(Spreadsheet spreadsheet,
                                               com.hp.hpl.jena.rdf.model.Resource config)
                                        throws java.io.IOException
Throws:
java.io.IOException

getCommasplitItems

public static java.lang.String[] getCommasplitItems(java.lang.String source,
                                                    com.hp.hpl.jena.rdf.model.Resource config,
                                                    java.util.Set ignoreListSpecialCheck)

getExistingFile

public static java.io.File getExistingFile(java.lang.String fileName)

getExistingFileSource

public static java.lang.Object getExistingFileSource(java.lang.String fileName)

getExistingResource

public static org.eclipse.core.resources.IFile getExistingResource(java.lang.String fileName)

getExistingURL

public static java.net.URL getExistingURL(java.lang.String fileName)

getImportMessage

public static java.lang.String getImportMessage(com.hp.hpl.jena.rdf.model.Resource config)

getInverse

public static java.lang.String getInverse(java.lang.Object input)
Get the inverse of COLUMN / ROW

Parameters:
input -
Returns:

getInverse

public static java.lang.Object getInverse(java.lang.Object input,
                                          java.lang.Object first,
                                          java.lang.Object second)
Get the inverse identifier.

Parameters:
input -
first -
second -
Returns:
first if input = second or vice versa

getItem

public static java.lang.String getItem(java.lang.String source,
                                       com.hp.hpl.jena.rdf.model.Resource config)

getItem

public static java.lang.String getItem(java.lang.String source,
                                       java.lang.String localName,
                                       com.hp.hpl.jena.rdf.model.Resource config)

getItem

public static java.lang.String getItem(java.lang.String source,
                                       java.lang.String localName,
                                       com.hp.hpl.jena.rdf.model.Resource config,
                                       java.util.Set ignoreSpecialCheck)

getItem

public static void getItem(java.lang.String source,
                           java.lang.StringBuffer result,
                           java.lang.String localName,
                           com.hp.hpl.jena.rdf.model.Resource config)

getItem

public static void getItem(java.lang.String source,
                           java.lang.StringBuffer result,
                           java.lang.String localName,
                           com.hp.hpl.jena.rdf.model.Resource config,
                           java.util.Set ignoreSpecialCheck)

getItems

public static java.lang.String[] getItems(java.lang.String source,
                                          java.lang.String splitter,
                                          java.lang.String surrounder,
                                          com.hp.hpl.jena.rdf.model.Resource config)

getItems

public static java.lang.String[] getItems(java.lang.String source,
                                          java.lang.String splitter,
                                          java.lang.String surrounder,
                                          com.hp.hpl.jena.rdf.model.Resource config,
                                          java.util.Set ignoreSpecialCheck)

getItems

public static java.lang.String[] getItems(java.lang.String source,
                                          java.lang.String localName,
                                          java.lang.String splitter,
                                          java.lang.String surrounder,
                                          com.hp.hpl.jena.rdf.model.Resource config,
                                          java.util.Set ignoreSpecialCheck)

getOrderedPropertyColumns

public static java.util.List<java.lang.String> getOrderedPropertyColumns(java.lang.String[] colNames,
                                                                         com.hp.hpl.jena.rdf.model.Resource config)

getOrderedPropertyColumns

public static java.util.List<java.lang.String> getOrderedPropertyColumns(java.lang.String[] colNames,
                                                                         java.lang.String idPattern)

getPropertyDetails

public static com.hp.hpl.jena.rdf.model.Resource getPropertyDetails(java.lang.String colName,
                                                                    com.hp.hpl.jena.rdf.model.Resource config)

getResource

public static com.hp.hpl.jena.rdf.model.Resource getResource(com.hp.hpl.jena.rdf.model.Model model,
                                                             java.lang.String rawLabel)
                                                      throws java.lang.Exception
Throws:
java.lang.Exception

getResource

public static com.hp.hpl.jena.rdf.model.Resource getResource(com.hp.hpl.jena.rdf.model.Model model,
                                                             java.lang.String rawLabel,
                                                             com.hp.hpl.jena.rdf.model.Resource config)
                                                      throws java.lang.Exception
Gets a resource already existing in the model. It can be anonymous. The resource doesn't have to have an rdf:type. This is convenience for resources that are "just" created from the spreadsheet and don't have rdf:type. Uses the special character policy from options if options is not null.

Parameters:
model -
rawLabel -
options -
Returns:
Throws:
java.lang.Exception

getResource

public static org.eclipse.core.resources.IFile getResource(java.lang.String fileLocation)

getResourceByName

public static com.hp.hpl.jena.rdf.model.Resource getResourceByName(com.hp.hpl.jena.rdf.model.Model model,
                                                                   java.lang.String qName)
Deprecated. - will be moved to Labels.java

Parameters:
model -
qName -
Returns:

getSchema

public static java.lang.String getSchema(java.lang.String uri)

getSetElement

public static java.util.Set getSetElement(java.util.Map map,
                                          java.lang.Object key)

getSpreedsheetFromURL

public static Spreadsheet getSpreedsheetFromURL(java.lang.String url)

getSpreadsheetFromSource

public static Spreadsheet getSpreadsheetFromSource(java.lang.Object fileSource)

getTypesOfLabel

public static void getTypesOfLabel(java.util.List<java.lang.Object> classes,
                                   java.lang.String rowHead,
                                   com.hp.hpl.jena.rdf.model.Model model,
                                   com.hp.hpl.jena.rdf.model.Resource config)
                            throws java.lang.Exception
Throws:
java.lang.Exception

getUnsurroundedString

public static java.lang.String getUnsurroundedString(java.lang.String sourceStr,
                                                     java.lang.String surroundStr)

getURIFlex

public static java.lang.String getURIFlex(com.hp.hpl.jena.rdf.model.Model model,
                                          java.lang.String qName)
Deprecated. - will be moved to Labels.java

Parameters:
model -
qName -
Returns:

guessClass

public static void guessClass(Spreadsheet spreadsheet,
                              com.hp.hpl.jena.rdf.model.Model model,
                              int maxAllowed,
                              java.lang.String[] classNames,
                              java.util.List<java.util.List> returnList,
                              com.hp.hpl.jena.rdf.model.Resource config,
                              int position,
                              java.lang.String location)
                       throws java.lang.Exception,
                              java.io.IOException
Throws:
java.lang.Exception
java.io.IOException

guessClass

public static java.util.List[] guessClass(Spreadsheet spreadsheet,
                                          com.hp.hpl.jena.rdf.model.Resource config,
                                          com.hp.hpl.jena.rdf.model.Model model,
                                          int maxAllowed)

guessClass

public static java.util.List guessClass(Spreadsheet ss,
                                        java.lang.String position,
                                        com.hp.hpl.jena.rdf.model.Model model,
                                        com.hp.hpl.jena.rdf.model.Resource config,
                                        int maxAllowed)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

isColumnNameChecked

public static boolean isColumnNameChecked(java.lang.String colName,
                                          com.hp.hpl.jena.rdf.model.Resource config)

isSpreadsheetEmpty

public static boolean isSpreadsheetEmpty(Spreadsheet spreadsheet)
                                  throws java.lang.Exception
Throws:
java.lang.Exception

isSurroundedWith

public static boolean isSurroundedWith(java.lang.String sourceStr,
                                       java.lang.String surroundStr)

mapObject

public static java.lang.Object mapObject(com.hp.hpl.jena.rdf.model.Model model,
                                         java.lang.String rawLabel,
                                         com.hp.hpl.jena.rdf.model.Resource subject,
                                         com.hp.hpl.jena.rdf.model.Resource predicate,
                                         com.hp.hpl.jena.rdf.model.Resource config)
                                  throws java.lang.Exception
Throws:
java.lang.Exception

mapResource

public static com.hp.hpl.jena.rdf.model.Resource mapResource(com.hp.hpl.jena.rdf.model.Model model,
                                                             java.lang.String rawLabel)
                                                      throws java.lang.Exception
Throws:
java.lang.Exception

mapResource

public static com.hp.hpl.jena.rdf.model.Resource mapResource(com.hp.hpl.jena.rdf.model.Model model,
                                                             java.lang.String rawLabel,
                                                             com.hp.hpl.jena.rdf.model.Resource config)
                                                      throws java.lang.Exception
Maps the rawLabel to a resource in model. The rawLabel can be anonymous. Uses the special character policy from options if options is not null.

Parameters:
model -
rawLabel -
options -
Returns:
Throws:
java.lang.Exception

parseLiteral

public static java.lang.String parseLiteral(java.lang.String source)

putSetElement

public static boolean putSetElement(java.util.Map<java.lang.Object,java.util.Set> map,
                                    java.lang.Object key,
                                    java.lang.Object value)

unionURIs

public static java.lang.String unionURIs(java.lang.String uri1,
                                         java.lang.String uri2)
Generates a URI with a union of the general and local parts of the URI

Parameters:
uri1 -
uri2 -
Returns:

addProperty

public static void addProperty(com.hp.hpl.jena.rdf.model.Resource resource,
                               com.hp.hpl.jena.rdf.model.Property property,
                               java.lang.String lexicalValue,
                               com.hp.hpl.jena.datatypes.RDFDatatype rdfDatatype)

addProperty

public static void addProperty(com.hp.hpl.jena.rdf.model.Resource resource,
                               com.hp.hpl.jena.rdf.model.Property property,
                               java.lang.String lexicalValue)