public ContentType getResponseContentType() { if (!executed) { throw new IllegalStateException( "Must call execute() before attempting to read response"); } String value = httpConn.getHeaderField("Content-Type"); if (value == null) { return null; } return new ContentType(value); }
/** The mime type of the collection */ public String getType() { return ContentType.getAtomFeed().toString(); }
public void setType(String type) { assertNotLocked(); this.type = type; }
@Override public String getType() { return ContentType.getAtomEntry().toString(); }
/** * Sets the MIME type for the content of the error message contained in this * element. * * @param contentType MIME type for the content of the error message contained * in this element or <code>null</code> to reset */ public BatchStatus setContentType(ContentType contentType) { setAttributeValue(CONTENT_TYPE, (contentType == null) ? null : new ContentType(contentType.getMediaType())); return this; }
acceptedContentType = new ContentType(acceptedTypeString.trim()); } catch (IllegalArgumentException ex) { String qAttr = acceptedContentType.getAttribute("q"); if (qAttr != null) { float qValue = Float.valueOf(qAttr); if (actualContentType.match(acceptedContentType)) { bestContentType = actualContentType; bestQ = curQ;
/** * Generate an Atom XML representation of the current object. */ @Override public void generate(XmlWriter w, ExtensionProfile extProfile) throws IOException { List<XmlWriter.Attribute> attributes = new ArrayList<XmlWriter.Attribute>(4); if (code > 0) { attributes.add(new XmlWriter.Attribute("code", Integer.toString(code))); } if (reason != null) { attributes.add(new XmlWriter.Attribute("reason", reason)); } if (contentType != null) { // Charset makes no sense in this context contentType.getAttributes().remove(ContentType.ATTR_CHARSET); attributes.add(new XmlWriter.Attribute("content-type", contentType.toString())); } generateStartElement(w, Namespaces.batchNs, "status", attributes, null); generateExtensions(w, extProfile); if (content != null) { w.characters(content); } w.endElement(Namespaces.batchNs, "status"); }
new ContentType(httpConn.getContentType()); initialException.responseContentType = responseContentType; String charset = responseContentType.getAttributes().get("charset"); if (charset == null) { charset = "iso8859-1"; // http default encoding
/** Specifies the MIME Content type. */ public void setMimeType(ContentType v) { setAttributeValue(TYPE, (v == null ? null : v.getMediaType())); }
if ((se.getResponseContentType().equals(new ContentType("text/xml"))) && (se.getResponseBody().contains("AppsForYourDomainErrors"))) { try {
/** * Returns the alt format that has been registered with the specified content * type. * * @param contentType type to look up. * @return registered format matching the type or {@code null}. */ public AltFormat lookupType(ContentType contentType) { // Do a direct lookup by media type first (fast) AltFormat format = typeMap.get(contentType.getMediaType()); if (format == null) { // If no match, use MIME type matching algorithm (slower but more precise) for (AltFormat testFormat : typeMap.values()) { if (contentType.match(testFormat.getContentType())) { format = testFormat; break; } } } if (format == null && delegate != null) { return delegate.lookupType(contentType); } return format; }
public String getContentType() { return ContentType.MESSAGE_RFC822.toString(); }
/** * Returns the expected character set encoding for content based upon the * input properties content type. * * @param inProps input properties * @return expected character set encoding */ protected String getCharset(InputProperties inProps) { return inProps.getContentType().getCharset(); }
/** * Compares the optional 'type' attribute of two content types. * * <p>This method accepts atom content type without the 'type' attribute * but if the types are specified, they must match. */ private boolean matchAtom(ContentType acceptedContentType) { String atomType = getAttribute("type"); String acceptedAtomType = acceptedContentType.getAttribute("type"); return atomType == null || acceptedAtomType == null || atomType.equals(acceptedAtomType); }
public void parse(ContentType contentType, String body) throws ParseException { if (ContentType.GDATA_ERROR.equals(contentType)) { XmlParser xp = new XmlParser(); try { xp.parse(new StringReader(body), new ErrorsHandler(), "http://schemas.google.com/g/2005", "errors"); } catch (IOException ioe) { // Impossible case: we are always parsing from a String throw new RuntimeException("Impossible parser I/O", ioe); } } }
/** * Sets the MIME type of the content of this element. * * @param contentType MIME type of the content of this element or * <code>null</code> to reset */ public BatchInterrupted setContentType(ContentType contentType) { setAttributeValue(CONTENT_TYPE, (contentType == null) ? null : new ContentType(contentType.getMediaType())); return this; }
acceptedContentType = new ContentType(acceptedTypeString.trim()); } catch (IllegalArgumentException ex) { String qAttr = acceptedContentType.getAttribute("q"); if (qAttr != null) { float qValue = Float.valueOf(qAttr); if (actualContentType.match(acceptedContentType)) { bestContentType = actualContentType; bestQ = curQ;
/** * Generate an Atom XML representation of the current object. */ @Override public void generate(XmlWriter w, ExtensionProfile extProfile) throws IOException { List<XmlWriter.Attribute> attributes = new ArrayList<XmlWriter.Attribute>(4); if (code > 0) { attributes.add(new XmlWriter.Attribute("code", Integer.toString(code))); } if (reason != null) { attributes.add(new XmlWriter.Attribute("reason", reason)); } if (contentType != null) { // Charset makes no sense in this context contentType.getAttributes().remove(ContentType.ATTR_CHARSET); attributes.add(new XmlWriter.Attribute("content-type", contentType.toString())); } generateStartElement(w, Namespaces.batchNs, "status", attributes, null); generateExtensions(w, extProfile); if (content != null) { w.characters(content); } w.endElement(Namespaces.batchNs, "status"); }
new ContentType(httpConn.getContentType()); initialException.responseContentType = responseContentType; String charset = responseContentType.getAttributes().get("charset"); if (charset == null) { charset = "iso8859-1"; // http default encoding
/** Specifies the MIME type. */ public void setMimeType(ContentType v) { setAttributeValue(TYPE, v.getMediaType()); }