Ok, I run the code.
But the results don't give me the expected (from my perspective :-) )
results.
Here is the simple code (Thank you Nick):
List<MediaType> mts = new ArrayList<MediaType>();
// All of these should return XML type
mts.add(MediaType.parse("text/xml"));
mts.add(MediaType.parse("application/xml"));
mts.add(MediaType.parse("application/x-xml"));
mts.add(MediaType.parse("application/atom+xml"));
mts.add(MediaType.parse("application/rss+xml"));
// All of these should return Compress or ZIP type
mts.add(MediaType.parse("application/gzip"));
mts.add(MediaType.parse("application/x-gzip"));
mts.add(MediaType.parse("application/x-gunzip"));
mts.add(MediaType.parse("application/gzipped"));
mts.add(MediaType.parse("application/gzip-compressed"));
mts.add(MediaType.parse("application/x-compress"));
mts.add(MediaType.parse("gzip/document"));
AutoDetectParser parser = new AutoDetectParser();
MediaTypeRegistry registry = parser.getMediaTypeRegistry();
for (MediaType mediaType : mts) {
System.out.println("Original: " + mediaType.toString());
MediaType supertype = registry.getSupertype(mediaType);
System.out.println(" supertype: " + supertype);
}
* Please note that I didn't loop/recurse because each one of the above has
only 1 parent, so recursing with my types didn't yield different results
* Please note that I hoped the first group to parse to
MediaType.APPLICATION_XML
* Please note that I hoped the second group to parse to
MediaType.APPLICATION_ZIP
The results are as follows:
Original: text/xml
supertype: text/plain
Original: application/xml
supertype: text/plain
Original: application/x-xml
supertype: application/octet-stream
Original: application/atom+xml
supertype: application/xml
Original: application/rss+xml
supertype: application/xml
Original: application/gzip
supertype: application/octet-stream
Original: application/x-gzip
supertype: application/octet-stream
Original: application/x-gunzip
supertype: application/octet-stream
Original: application/gzipped
supertype: application/octet-stream
Original: application/gzip-compressed
supertype: application/octet-stream
Original: application/x-compress
supertype: application/octet-stream
Original: gzip/document
supertype: application/octet-stream
As you can see from the results:
* The first two types parse to "text/plain" which is not good for me.
* The third type parsed to "octet-stream" which isn't as hoped also
* All of compressed types parsed to "octet-stream" which doesn't really
help me either
On Wed, Apr 23, 2014 at 1:52 PM, אברהם חיון <[email protected]> wrote:
> Thank you Nick.
>
>
> Using that code I can easily recurse to the parent MediaType.
>
>
> I wonder who the main parents are, but I will try it tonight and see what
> I get.
>
>
> I will report my success / failure.
>
>
>
> Thanks,
> Avi.
>
>
>
> On Wed, Apr 23, 2014 at 1:29 PM, Nick Burch <[email protected]> wrote:
>
>> On Wed, 23 Apr 2014, אברהם חיון wrote:
>>
>>> I need to download the Tika source code for that and I am still at work.
>>>
>>
>> It's all in SVN, so you can just browse it:
>> http://svn.apache.org/viewvc/tika/trunk/tika-app/src/main/
>> java/org/apache/tika/cli/TikaCLI.java?view=markup
>>
>> And view it raw:
>> http://svn.apache.org/repos/asf/tika/trunk/tika-app/src/
>> main/java/org/apache/tika/cli/TikaCLI.java
>>
>> Nick
>
>
>