// Path: ui/src/content/jcr_root/libs/foundation/src/impl/src/main/java/com/day/cq/wcm/foundation/External.java
// public static enum Limit {
// 
//     NO("no"),
//     HOST("host"),
//     OFF("off");
// 
//     private final String value;
// 
//     private Limit(String value) {
//         this.value = value;
//     }
// 
//     @Override
//     public String toString() {
//         return value;
//     }
// }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.PushbackInputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.StringPart;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.rewriter.htmlparser.AttributeList;
import com.day.cq.rewriter.htmlparser.DocumentHandler;
import com.day.cq.rewriter.htmlparser.HtmlParser;
import com.day.cq.wcm.foundation.External.Limit;
import com.day.text.Text;
/*
 * $Id: Rewriter.java 60840 2009-11-13 16:39:48Z cziegele $
 *
 * Copyright (c) 1997-2003 Day Management AG
 * Barfuesserplatz 6, 4001 Basel, Switzerland
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * Day Management AG, ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Day.
 */
package com.day.cq.wcm.foundation.impl;





/**
 * Central rewriter that rewrites HTML pages to pass over its own rewriting
 * engine.
 */
public class Rewriter implements DocumentHandler {

    /**
     * Logger.
     */
    private static final Logger log = LoggerFactory.getLogger(Rewriter.class);

    /**
     * Path to current page.
     */
    private final String pagePath;

    /**
     * Path to current resource.
     */
    private final String resourcePath;

    /**
     * Target to show.
     */
    private final String target;

    /**
     * Reserved parameter name for target URL.
     */
    private final String targetParamName;

    /**
     * Limit, one of {@link Limit#NO}, {@link Limit#HOST}, {@link Limit#OFF}.
     */
// Path: ui/src/content/jcr_root/libs/foundation/src/impl/src/main/java/com/day/cq/wcm/foundation/External.java
// public static enum Limit {
// 
//     NO("no"),
//     HOST("host"),
//     OFF("off");
// 
//     private final String value;
// 
//     private Limit(String value) {
//         this.value = value;
//     }
// 
//     @Override
//     public String toString() {
//         return value;
//     }
// }


// Path: ui/src/content/jcr_root/libs/foundation/src/impl/src/main/java/com/day/cq/wcm/foundation/impl/Rewriter.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.PushbackInputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.StringPart;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.rewriter.htmlparser.AttributeList;
import com.day.cq.rewriter.htmlparser.DocumentHandler;
import com.day.cq.rewriter.htmlparser.HtmlParser;
import com.day.cq.wcm.foundation.External.Limit;
import com.day.text.Text;

/*
 * $Id: Rewriter.java 60840 2009-11-13 16:39:48Z cziegele $
 *
 * Copyright (c) 1997-2003 Day Management AG
 * Barfuesserplatz 6, 4001 Basel, Switzerland
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * Day Management AG, ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Day.
 */
package com.day.cq.wcm.foundation.impl;





/**
 * Central rewriter that rewrites HTML pages to pass over its own rewriting
 * engine.
 */
public class Rewriter implements DocumentHandler {

    /**
     * Logger.
     */
    private static final Logger log = LoggerFactory.getLogger(Rewriter.class);

    /**
     * Path to current page.
     */
    private final String pagePath;

    /**
     * Path to current resource.
     */
    private final String resourcePath;

    /**
     * Target to show.
     */
    private final String target;

    /**
     * Reserved parameter name for target URL.
     */
    private final String targetParamName;

    /**
     * Limit, one of {@link Limit#NO}, {@link Limit#HOST}, {@link Limit#OFF}.
     */
    private Limit limit = Limit.NO;