MCPcopy Create free account
hub / github.com/GateNLP/gate-core / getDocumentFormat

Method getDocumentFormat

src/main/java/gate/DocumentFormat.java:500–524  ·  view source on GitHub ↗

Find a DocumentFormat implementation that deals with a particular MIME type, given that type. @param aGateDocument this document will receive as a feature the associated Mime Type. The name of the feature is MimeType and its value is in the format type/subt

(gate.Document aGateDocument,
                                                            MimeType mimeType)

Source from the content-addressed store, hash-verified

498 * @param mimeType the mime type that is given as input
499 */
500 static public DocumentFormat getDocumentFormat(gate.Document aGateDocument,
501 MimeType mimeType){
502 FeatureMap aFeatureMap = null;
503 if(mimeType == null) {
504 String content = aGateDocument.getContent().toString();
505 // reduce size for better performance
506 if(content.length() > 2048) content = content.substring(0, 2048);
507 mimeType = getTypeFromContent( content );
508 }
509
510 if (mimeType != null){
511 // If the Gate Document doesn't have a feature map atached then
512 // We will create and set one.
513 if(aGateDocument.getFeatures() == null){
514 aFeatureMap = Factory.newFeatureMap();
515 aGateDocument.setFeatures(aFeatureMap);
516 }// end if
517 aGateDocument.getFeatures().put("MimeType",mimeType.getType() + "/" +
518 mimeType.getSubtype());
519
520 return mimeString2ClassHandlerMap.get(mimeType.getType()
521 + "/" + mimeType.getSubtype());
522 }// end If
523 return null;
524 } // getDocumentFormat(aGateDocument, MimeType)
525
526 /**
527 * Find a DocumentFormat implementation that deals with a particular

Callers 6

willReadFromUrlMethod · 0.95
initMethod · 0.95
testUnpackMarkupMethod · 0.80
testUnpackMarkupMethod · 0.80
testSgmlLoadingMethod · 0.80

Calls 12

getTypeFromContentMethod · 0.95
newFeatureMapMethod · 0.95
getMimeTypeMethod · 0.95
getSubtypeMethod · 0.80
toStringMethod · 0.65
getContentMethod · 0.65
getFeaturesMethod · 0.65
setFeaturesMethod · 0.65
getTypeMethod · 0.65
getMethod · 0.65
lengthMethod · 0.45
putMethod · 0.45

Tested by 4

testUnpackMarkupMethod · 0.64
testUnpackMarkupMethod · 0.64
testSgmlLoadingMethod · 0.64