Package org.cip4.jdflib.validate
Class JDFValidator
- java.lang.Object
-
- org.cip4.jdflib.validate.JDFValidator
-
public class JDFValidator extends java.lang.Objectthis is the non-commandline part of the original checkJDF and used both by the JDF Editor and checkJDF Refactored JDFValidator to be non-static in order to make it thread compatible. Previously, only one thread at a time could call JDFValidator from within the same JVM. Now an instance of JDFValidator and the the method validate should be called. JDFValidator can still be called from the command line in the same way as before. TODO Break out validation error handling logging so that new error handlers can easily be registered. For example, there should be an error handler for logging to the XML log file and an error handler for logging to thesysOut. Perhapsorg.xml.sax.ErrorHandlercould be used?
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classJDFValidator.MySysOutThis is just a quick and dirty class to centrally switch print on and off
-
Field Summary
Fields Modifier and Type Field Description VStringallFilesbooleanbMultiIDprotected booleanbPrintNameSpacebooleanbQuietDeprecated.booleanbTimingDeprecated.booleanbValidatebooleanbWarnDanglingURLif true, warn on URL attributes that point to Nirvanaprotected booleanbWarningjava.lang.StringdevCapFileJDFElement.EnumValidationLevellevelprotected XMLDocpOutjava.lang.StringproxyHostjava.lang.StringproxyPortjava.lang.StringschemaLocationprotected JDFValidator.MySysOutsysOutJDFBaseDataTypes.EnumFitsValuetestlistsprotected java.lang.StringtranslationVStringvBadIDprotected static java.lang.StringversionVStringvMultiIDjava.lang.StringxmlOutputNamejava.lang.StringxslStyleSheet
-
Constructor Summary
Constructors Constructor Description JDFValidator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddFile(java.lang.String xmlFile)protected voidfillDoc(java.io.InputStream inStream, java.lang.String xmlFile, javax.mail.BodyPart bp)protected java.lang.StringgetInvalidText(JDFElement jdfElement)protected KElementgetTestElement(KElement kElement, KElement xmlParent)protected voidhandleNull(java.lang.String xmlFile, KElement testFileRoot)booleanisBWarning()booleanisValid(JDFDoc doc)process a single document as specified by doc if doc==null, reprocess the currently stored documentprotected JDFElementprintBadJDF(KElement kElement, int indent, KElement xmlParent, boolean bIsNodeRoot, java.lang.String id, java.lang.String elmName, KElement testElement, boolean bIsValid)protected booleanprintBadTarget(JDFResourceLink rl, int indent, KElement testElement, java.lang.String rRef, java.lang.String resLinkName, java.lang.String procUsage, java.lang.String errMessage, JDFResource res)protected voidprintBaseBadResLink(JDFResourceLink rl, KElement testElement, java.lang.String rRef)protected booleanprintDanglingRefElement(JDFRefElement re, int indent, KElement testElement, java.lang.String rRef, java.lang.String refName, java.lang.String errMessage)protected booleanprintDanglingResLink(JDFResourceLink rl, int indent, KElement testElement, java.lang.String rRef, java.lang.String resLinkName, java.lang.String procUsage, java.lang.String errMessage)protected voidprintInvalidLinkInNode(JDFResourceLink rl, KElement testElement, JDFNode n)protected booleanprintInvalidRefElem(JDFRefElement re, int indent, KElement testElement, java.lang.String rRef, java.lang.String refName, java.lang.String errMessage, KElement targEl)protected voidprintNonNamespace(KElement kElement, int indent, KElement reportParent, java.lang.String pref, java.lang.String elmName, java.lang.String nsURI, KElement testElement, boolean isJDFNS, boolean bTypo)protected voidprintRealDevCap(KElement testElement, JDFNode jdfNode, JDFJMF jmfRoot)protected voidprintSemiValidReslink(JDFResourceLink rl, KElement testElement, JDFResource res)protected booleanprintSingleRefElem(JDFRefElement re, int indent, KElement testElement, boolean isValid, java.lang.String rRef, java.lang.String refName, java.lang.String errMessage)XMLDocprocessAllFiles()processes all files that have been placed into the public VString member JDFValidator.allFilesXMLDocprocessMimeStream(java.io.InputStream inStream)process a mime fileprotected voidprocessSingleDoc(java.lang.String url, java.lang.String xmlFile, KElement testFileRoot)XMLDocprocessSingleDocument(JDFDoc doc)process a single document as specified by doc if doc==null, reprocess the currently stored documentXMLDocprocessSingleFile(java.io.InputStream inStream, java.lang.String url, java.lang.String xmlFile)Deprecated.- use either processSingleDoc, processSingleStream or processSinglFile(String) this will be made privateprotected XMLDocprocessSingleFile(java.io.InputStream inStream, java.lang.String url, java.lang.String xmlFile, javax.mail.BodyPart bp)processes a single fileXMLDocprocessSingleFile(java.lang.String fileName)process a single file document as specified by fileNameprotected voidprocessSingleJDF(java.lang.String url, java.lang.String xmlFile, KElement testFileRoot, KElement checkJDFxmlRoot, JDFNode root)XMLDocprocessSingleStream(java.io.InputStream stream, java.lang.String fileName, javax.mail.BodyPart bp)process a single document as specified by docXMLDocprocessSingleURLStream(java.io.InputStream stream, java.lang.String url)process a single document as specified by docXMLDocprocessZipFile(java.io.File argFile)we may want to create something similar for a zip streamprotected voidreset()protected voidsetAllFiles(MyArgs args)voidsetDoc(JDFDoc d)set the JDFDoc (JDF or JMF) to setvoidsetIgnorePrivate(boolean bIgnore)if bIvoidsetJDFSchemaLocation(java.io.File _schemaLocation)voidsetJDFSchemaLocation(java.lang.String _schemaLocation)this can be either a file or a network urlvoidsetPrint(boolean b)sets the System.out print on or offvoidsetValidatorFactory(ICheckValidatorFactory pvalidatorFactory)voidsetWarning(boolean warning)static java.lang.StringtoMessageString(KElement checkOut)
-
-
-
Field Detail
-
vBadID
public VString vBadID
-
vMultiID
public VString vMultiID
-
pOut
protected XMLDoc pOut
-
translation
protected java.lang.String translation
-
bTiming
@Deprecated public boolean bTiming
Deprecated.
-
bWarning
protected boolean bWarning
-
bQuiet
@Deprecated public boolean bQuiet
Deprecated.
-
bPrintNameSpace
protected boolean bPrintNameSpace
-
bValidate
public boolean bValidate
-
bWarnDanglingURL
public boolean bWarnDanglingURL
if true, warn on URL attributes that point to Nirvana
-
level
public JDFElement.EnumValidationLevel level
-
allFiles
public VString allFiles
-
proxyHost
public java.lang.String proxyHost
-
proxyPort
public java.lang.String proxyPort
-
schemaLocation
public java.lang.String schemaLocation
-
xmlOutputName
public java.lang.String xmlOutputName
-
xslStyleSheet
public java.lang.String xslStyleSheet
-
devCapFile
public java.lang.String devCapFile
-
testlists
public JDFBaseDataTypes.EnumFitsValue testlists
-
bMultiID
public boolean bMultiID
-
version
protected static final java.lang.String version
-
sysOut
protected JDFValidator.MySysOut sysOut
-
-
Method Detail
-
toMessageString
public static java.lang.String toMessageString(KElement checkOut)
- Parameters:
checkOut-- Returns:
-
setDoc
public void setDoc(JDFDoc d)
set the JDFDoc (JDF or JMF) to set- Parameters:
d- the JDFDoc to set this to
-
setIgnorePrivate
public void setIgnorePrivate(boolean bIgnore)
if bI- Parameters:
bIgnore-
-
setPrint
public void setPrint(boolean b)
sets the System.out print on or off- Parameters:
b-
-
printBadJDF
protected JDFElement printBadJDF(KElement kElement, int indent, KElement xmlParent, boolean bIsNodeRoot, java.lang.String id, java.lang.String elmName, KElement testElement, boolean bIsValid)
-
printNonNamespace
protected void printNonNamespace(KElement kElement, int indent, KElement reportParent, java.lang.String pref, java.lang.String elmName, java.lang.String nsURI, KElement testElement, boolean isJDFNS, boolean bTypo)
-
getInvalidText
protected java.lang.String getInvalidText(JDFElement jdfElement)
-
printSingleRefElem
protected boolean printSingleRefElem(JDFRefElement re, int indent, KElement testElement, boolean isValid, java.lang.String rRef, java.lang.String refName, java.lang.String errMessage)
-
printInvalidRefElem
protected boolean printInvalidRefElem(JDFRefElement re, int indent, KElement testElement, java.lang.String rRef, java.lang.String refName, java.lang.String errMessage, KElement targEl)
-
printDanglingRefElement
protected boolean printDanglingRefElement(JDFRefElement re, int indent, KElement testElement, java.lang.String rRef, java.lang.String refName, java.lang.String errMessage)
-
printBadTarget
protected boolean printBadTarget(JDFResourceLink rl, int indent, KElement testElement, java.lang.String rRef, java.lang.String resLinkName, java.lang.String procUsage, java.lang.String errMessage, JDFResource res)
-
printSemiValidReslink
protected void printSemiValidReslink(JDFResourceLink rl, KElement testElement, JDFResource res)
-
printInvalidLinkInNode
protected void printInvalidLinkInNode(JDFResourceLink rl, KElement testElement, JDFNode n)
-
printDanglingResLink
protected boolean printDanglingResLink(JDFResourceLink rl, int indent, KElement testElement, java.lang.String rRef, java.lang.String resLinkName, java.lang.String procUsage, java.lang.String errMessage)
-
printBaseBadResLink
protected void printBaseBadResLink(JDFResourceLink rl, KElement testElement, java.lang.String rRef)
-
printRealDevCap
protected void printRealDevCap(KElement testElement, JDFNode jdfNode, JDFJMF jmfRoot)
-
setJDFSchemaLocation
public void setJDFSchemaLocation(java.lang.String _schemaLocation)
this can be either a file or a network url- Parameters:
_schemaLocation-
-
setJDFSchemaLocation
public void setJDFSchemaLocation(java.io.File _schemaLocation)
- Parameters:
_schemaLocation- the schema location
-
processAllFiles
public XMLDoc processAllFiles()
processes all files that have been placed into the public VString member JDFValidator.allFiles- Returns:
- XMLDoc the xml output document
-
processZipFile
public XMLDoc processZipFile(java.io.File argFile)
we may want to create something similar for a zip stream- Parameters:
argFile-- Returns:
- XMLDoc the output file
-
processMimeStream
public XMLDoc processMimeStream(java.io.InputStream inStream)
process a mime file- Parameters:
argFile-- Returns:
-
processSingleDocument
public XMLDoc processSingleDocument(JDFDoc doc)
process a single document as specified by doc if doc==null, reprocess the currently stored document- Parameters:
doc- the parsed document to process- Returns:
- the xml output of the validation
-
isValid
public boolean isValid(JDFDoc doc)
process a single document as specified by doc if doc==null, reprocess the currently stored document- Parameters:
doc- the parsed document to process- Returns:
- the xml output of the validation
-
processSingleURLStream
public XMLDoc processSingleURLStream(java.io.InputStream stream, java.lang.String url)
process a single document as specified by doc- Parameters:
stream- the input streamurl- the url that the stream is sent to- Returns:
- the xml output of the validation
-
processSingleStream
public XMLDoc processSingleStream(java.io.InputStream stream, java.lang.String fileName, javax.mail.BodyPart bp)
process a single document as specified by doc- Parameters:
stream- the input streamfileName- the fileName that the stream originated frombp-- Returns:
- the xml output of the validation
-
processSingleFile
public XMLDoc processSingleFile(java.lang.String fileName)
process a single file document as specified by fileName- Parameters:
fileName- the path of the file to parse and validate- Returns:
- the xml output of the validation
-
processSingleFile
@Deprecated public XMLDoc processSingleFile(java.io.InputStream inStream, java.lang.String url, java.lang.String xmlFile)
Deprecated.- use either processSingleDoc, processSingleStream or processSinglFile(String) this will be made privateprocesses a single file- Parameters:
inStream-url-xmlFile-- Returns:
-
processSingleFile
protected XMLDoc processSingleFile(java.io.InputStream inStream, java.lang.String url, java.lang.String xmlFile, javax.mail.BodyPart bp)
processes a single file- Parameters:
inStream-url-xmlFile-- Returns:
-
processSingleDoc
protected void processSingleDoc(java.lang.String url, java.lang.String xmlFile, KElement testFileRoot)
-
processSingleJDF
protected void processSingleJDF(java.lang.String url, java.lang.String xmlFile, KElement testFileRoot, KElement checkJDFxmlRoot, JDFNode root)
-
handleNull
protected void handleNull(java.lang.String xmlFile, KElement testFileRoot)
-
fillDoc
protected void fillDoc(java.io.InputStream inStream, java.lang.String xmlFile, javax.mail.BodyPart bp)
-
reset
protected void reset()
-
setAllFiles
protected void setAllFiles(MyArgs args)
-
addFile
public void addFile(java.lang.String xmlFile)
-
isBWarning
public boolean isBWarning()
- Returns:
- the bWarning
-
setWarning
public void setWarning(boolean warning)
- Parameters:
warning- the bWarning to set
-
setValidatorFactory
public void setValidatorFactory(ICheckValidatorFactory pvalidatorFactory)
- Parameters:
validatorFactory- the validatorFactory to set
-
-