// Path: src/main/java/org/firepick/firebom/exception/ProxyResolutionException.java
// public class ProxyResolutionException extends RuntimeException {
//     public ProxyResolutionException(Exception e) {
//         super(e);
//     }
// 
//     public ProxyResolutionException(String message) {
//         super(message);
//     }
// 
//     public ProxyResolutionException(String message, Exception e) {
//         super(message, e);
//     }
// }


import org.firepick.firebom.exception.ProxyResolutionException;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
  private static Pattern endTitle = Pattern.compile("\",");
  private static Pattern startPrice = Pattern.compile("\"PrceTxt\":\"");
  private static Pattern endPrice = Pattern.compile("\"");
  private static Pattern startPackageUnits = Pattern.compile("\"SellStdPkgQty\":");
  private static Pattern endPackageUnits = Pattern.compile(",");
  private static Pattern startDetail = Pattern.compile("data-mcm-attr-comp-itm-ids=\"");
  private static Pattern endDetail = Pattern.compile("\"");
  private static Pattern startDetailItem = Pattern.compile("#");
  private static Pattern endDetailIndex = Pattern.compile("$");
  private static Pattern startDetailPrice = Pattern.compile("\"PrceTxt\":\"\\$");
  private static Pattern endDetailPrice = Pattern.compile("[^0-9.]*\"");
  private static String userDataUrl = "http://www.mcmaster.com/UserData.aspx";
  private static String queryUrlTemplate =
    "http://www.mcmaster.com/WebParts/Ordering/InLnOrdWebPart/InLnOrdWebPart.aspx?cntnridtxt=InLnOrd_ItmBxRw_1_{PART}&partnbrtxt={PART}&multipartnbrind=false&partnbrslctdmsgcntxtnm=FullPrsnttn&autoslctdind=false";
  private static String detailQueryTemplate =
    "http://www.mcmaster.com/WebParts/Content/ItmPrsnttnWebPart.aspx?partnbrtxt={PART}&attrnm=&attrval=&attrcompitmids=&cntnridtxt=MainContent&proddtllnkclickedInd=true&cntnrWdth=1188";
  private static String detailPriceQueryTemplate =
    "http://www.mcmaster.com/WebParts/Content/ItmPrsnttnDynamicDat.aspx?acttxt=dynamicdat&partnbrtxt={PART}&isinlnspec=true&attrCompIds={DETAIL}";

  public McMasterCarrPart(PartFactory partFactory, URL url, CachedUrlResolver urlResolver) {
    super(partFactory, url, urlResolver);
  }

  @Override
  public URL normalizeUrl(URL url) {
    String normalizedUrl = url.toString().replaceAll("/=[a-zA-Z0-9]*", "");
    try {
      return new URL(normalizedUrl);
    }
    catch (MalformedURLException e) {
// Path: src/main/java/org/firepick/firebom/exception/ProxyResolutionException.java
// public class ProxyResolutionException extends RuntimeException {
//     public ProxyResolutionException(Exception e) {
//         super(e);
//     }
// 
//     public ProxyResolutionException(String message) {
//         super(message);
//     }
// 
//     public ProxyResolutionException(String message, Exception e) {
//         super(message, e);
//     }
// }


// Path: src/main/java/org/firepick/firebom/part/McMasterCarrPart.java
import org.firepick.firebom.exception.ProxyResolutionException;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

  private static Pattern endTitle = Pattern.compile("\",");
  private static Pattern startPrice = Pattern.compile("\"PrceTxt\":\"");
  private static Pattern endPrice = Pattern.compile("\"");
  private static Pattern startPackageUnits = Pattern.compile("\"SellStdPkgQty\":");
  private static Pattern endPackageUnits = Pattern.compile(",");
  private static Pattern startDetail = Pattern.compile("data-mcm-attr-comp-itm-ids=\"");
  private static Pattern endDetail = Pattern.compile("\"");
  private static Pattern startDetailItem = Pattern.compile("#");
  private static Pattern endDetailIndex = Pattern.compile("$");
  private static Pattern startDetailPrice = Pattern.compile("\"PrceTxt\":\"\\$");
  private static Pattern endDetailPrice = Pattern.compile("[^0-9.]*\"");
  private static String userDataUrl = "http://www.mcmaster.com/UserData.aspx";
  private static String queryUrlTemplate =
    "http://www.mcmaster.com/WebParts/Ordering/InLnOrdWebPart/InLnOrdWebPart.aspx?cntnridtxt=InLnOrd_ItmBxRw_1_{PART}&partnbrtxt={PART}&multipartnbrind=false&partnbrslctdmsgcntxtnm=FullPrsnttn&autoslctdind=false";
  private static String detailQueryTemplate =
    "http://www.mcmaster.com/WebParts/Content/ItmPrsnttnWebPart.aspx?partnbrtxt={PART}&attrnm=&attrval=&attrcompitmids=&cntnridtxt=MainContent&proddtllnkclickedInd=true&cntnrWdth=1188";
  private static String detailPriceQueryTemplate =
    "http://www.mcmaster.com/WebParts/Content/ItmPrsnttnDynamicDat.aspx?acttxt=dynamicdat&partnbrtxt={PART}&isinlnspec=true&attrCompIds={DETAIL}";

  public McMasterCarrPart(PartFactory partFactory, URL url, CachedUrlResolver urlResolver) {
    super(partFactory, url, urlResolver);
  }

  @Override
  public URL normalizeUrl(URL url) {
    String normalizedUrl = url.toString().replaceAll("/=[a-zA-Z0-9]*", "");
    try {
      return new URL(normalizedUrl);
    }
    catch (MalformedURLException e) {
      throw new ProxyResolutionException(url.toString(), e);