18
18
import java .io .IOException ;
19
19
import java .io .InputStream ;
20
20
import java .io .Reader ;
21
+ import java .nio .charset .Charset ;
21
22
import java .util .Arrays ;
22
23
import java .util .HashMap ;
23
24
import java .util .Map ;
49
50
class ContentTypeManager extends NoContentTypeSpecificHandling {
50
51
private final Map <String , IContentType > id2Object ;
51
52
private final IContentType processorStepType ;
53
+ private final IContentDescription processorStepDescription ;
52
54
53
55
/**
54
56
* Content type manager as required for cleanup steps.
@@ -66,6 +68,7 @@ class ContentTypeManager extends NoContentTypeSpecificHandling {
66
68
if (null == processorStepType ) {
67
69
throw new IllegalArgumentException ("The manager does not support content type " + formatterContentTypeID );
68
70
}
71
+ processorStepDescription = new StringDescription (processorStepType );
69
72
}
70
73
71
74
@ Override
@@ -83,6 +86,45 @@ public IContentType findContentTypeFor(InputStream contents, String fileName) th
83
86
return processorStepType ;
84
87
}
85
88
89
+ @ Override
90
+ public IContentDescription getDescriptionFor (InputStream contents , String fileName , QualifiedName [] options ) throws IOException {
91
+ return processorStepDescription ;
92
+ }
93
+
94
+ private static class StringDescription implements IContentDescription {
95
+
96
+ private final IContentType type ;
97
+
98
+ public StringDescription (IContentType type ) {
99
+ this .type = type ;
100
+ }
101
+
102
+ @ Override
103
+ public boolean isRequested (QualifiedName key ) {
104
+ return false ; //Don't use set Property
105
+ }
106
+
107
+ @ Override
108
+ public String getCharset () {
109
+ return Charset .defaultCharset ().name (); //Spotless operates on an decoded string, meaning the input has always the "internal" encoding
110
+ }
111
+
112
+ @ Override
113
+ public IContentType getContentType () {
114
+ return type ;
115
+ }
116
+
117
+ @ Override
118
+ public Object getProperty (QualifiedName key ) {
119
+ return null ; //Assume that the property map is empty
120
+ }
121
+
122
+ @ Override
123
+ public void setProperty (QualifiedName key , Object value ) {
124
+ throw new IllegalArgumentException ("Content description key cannot be set: " + key );
125
+ }
126
+ }
127
+
86
128
/**
87
129
* The WTP uses the manager only for ID mapping, so most of the methods are not used.
88
130
* Actually it has a hand stitched way for transforming the content type ID
0 commit comments