org.getwheat.harvest.library.dom.AbstractDomTransformer.java Source code

Java tutorial

Introduction

Here is the source code for org.getwheat.harvest.library.dom.AbstractDomTransformer.java

Source

package org.getwheat.harvest.library.dom;

import org.apache.http.client.methods.HttpUriRequest;
import org.getwheat.harvest.library.Transformer;

/*
 * Copyright 2011 by Christopher Smith
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

/**
 * AbstractDomTransformer is an abstract class that provides common Builder functionality for DOM
 * transformers.
 * 
 * @author Christopher Smith
 * 
 * @param <T> the Model class
 */
public abstract class AbstractDomTransformer<T> implements Transformer<T> {
    private static final String KEY_ACCEPT = "Accept";
    private static final String KEY_CONTENT_TYPE = "Content-Type";
    private static final String VALUE_MIME_XML = "application/xml";

    public void addContentTypeHeaders(final HttpUriRequest request) {
        request.addHeader(KEY_ACCEPT, VALUE_MIME_XML);
        request.addHeader(KEY_CONTENT_TYPE, VALUE_MIME_XML);
    }
}