Пример #1
0
 private String getAddressReverseGeocodeURL(GeoPoint gp) {
   //  -
   // http://nominatim.openstreetmap.org/reverse?format=xml&addressdetails=1&zoom=18&lat=46.17330&lon=21.29370
   StringBuffer sb = new StringBuffer();
   RTProperties rtp = this.getProperties();
   String url = rtp.getString(PROP_reverseURL, null);
   if (!StringTools.isBlank(url)) {
     sb.append(url);
   } else {
     String host = rtp.getString(PROP_hostName, HOST_PRIMARY);
     sb.append("http://");
     sb.append(host);
     if (host.indexOf("mapquest") >= 0) {
       sb.append("/nominatim/v1/reverse?");
     } else {
       sb.append("/reverse?");
     }
   }
   sb.append("format=xml&");
   sb.append("limit=1&");
   // sb.append("osm_type=W&");
   sb.append("addressdetails=").append(rtp.getString(PROP_addressdetails, "1")).append("&"); // 0,1
   sb.append("zoom=").append(rtp.getString(PROP_zoom, "18")).append("&"); // 0..18
   sb.append("email=").append(this.getEmail()).append("&"); // required, per usage policy
   sb.append("lat=").append(gp.getLatitudeString(GeoPoint.SFORMAT_DEC_5, null)).append("&");
   sb.append("lon=").append(gp.getLongitudeString(GeoPoint.SFORMAT_DEC_5, null));
   return sb.toString();
 }
Пример #2
0
  /**
   * Escape passed string as XML attibute value (<code>&lt;</code>, <code>&amp;</code>, <code>'
   * </code> and <code>"</code> will be escaped. Note: An XML processor returns normalized value
   * that can be different.
   *
   * @param val a string to be escaped
   * @return escaped value
   * @throws CharConversionException if val contains an improper XML character
   * @since 1.40
   */
  public static String toAttributeValue(String val) throws CharConversionException {

    if (val == null) throw new CharConversionException("null"); // NOI18N

    if (checkAttributeCharacters(val)) return val;

    StringBuffer buf = new StringBuffer();

    for (int i = 0; i < val.length(); i++) {
      char ch = val.charAt(i);
      if ('<' == ch) {
        buf.append("&lt;");
        continue;
      } else if ('&' == ch) {
        buf.append("&amp;");
        continue;
      } else if ('\'' == ch) {
        buf.append("&apos;");
        continue;
      } else if ('"' == ch) {
        buf.append("&quot;");
        continue;
      }
      buf.append(ch);
    }
    return buf.toString();
  }
  private void logResultInfo(
      int queryNr,
      int queryMixRun,
      double timeInSeconds,
      String queryString,
      byte queryType,
      int resultCount) {
    StringBuffer sb = new StringBuffer(1000);
    sb.append("\n\n\tQuery " + queryNr + " of run " + queryMixRun + " has been executed ");
    sb.append("in " + String.format("%.6f", timeInSeconds) + " seconds.\n");
    sb.append("\n\tQuery string:\n\n");
    sb.append(queryString);
    sb.append("\n\n");

    // Log results
    if (queryType == Query.DESCRIBE_TYPE)
      sb.append("\tQuery(Describe) result (" + resultCount + " Bytes): \n\n");
    else if (queryType == Query.CONSTRUCT_TYPE)
      sb.append("\tQuery(Construct) result (" + resultCount + " Bytes): \n\n");
    else sb.append("\tQuery results (" + resultCount + " results): \n\n");

    sb.append(
        "\n__________________________________________________________________________________\n");
    logger.log(Level.ALL, sb.toString());
  }
Пример #4
0
  /**
   * Can be used to encode values that contain invalid XML characters. At SAX parser end must be
   * used pair method to get original value.
   *
   * @param val data to be converted
   * @param start offset
   * @param len count
   * @since 1.29
   */
  public static String toHex(byte[] val, int start, int len) {

    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < len; i++) {
      byte b = val[start + i];
      buf.append(DEC2HEX[(b & 0xf0) >> 4]);
      buf.append(DEC2HEX[b & 0x0f]);
    }
    return buf.toString();
  }
Пример #5
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(processID + ",");
   sb.append(nodeID + ",");
   if (cofactor.equalsIgnoreCase("true")) {
     sb.append("cofactor");
   }
   sb.append("," + x + "," + y + "\n");
   return sb.toString();
 }
 /** @param tag */
 private String makeElementNameFromHexadecimalGroupElementValues(AttributeTag tag) {
   StringBuffer str = new StringBuffer();
   str.append("HEX"); // XML element names not allowed to start with a number
   String groupString = Integer.toHexString(tag.getGroup());
   for (int i = groupString.length(); i < 4; ++i) str.append("0");
   str.append(groupString);
   String elementString = Integer.toHexString(tag.getElement());
   for (int i = elementString.length(); i < 4; ++i) str.append("0");
   str.append(elementString);
   return str.toString();
 }
Пример #7
0
 public String toBeautifiedString() {
   StringBuffer sb = new StringBuffer();
   sb.append("PID: " + processID);
   sb.append("  Node id: " + nodeID);
   if (cofactor.equalsIgnoreCase("true")) {
     sb.append("\n is Cofactor. ");
   }
   sb.append("\n");
   sb.append("           x: " + x + " y: " + y + "\n\n");
   return sb.toString();
 }
 private String getFeatureIDs() {
   StringBuffer buffer = new StringBuffer();
   Object[] objects = fPage.getSelectedItems();
   for (int i = 0; i < objects.length; i++) {
     Object object = objects[i];
     if (object instanceof IFeatureModel) {
       buffer.append(((IFeatureModel) object).getFeature().getId());
       if (i < objects.length - 1) buffer.append(","); // $NON-NLS-1$
     }
   }
   return buffer.toString();
 }
Пример #9
0
 private static String readFileAsString(String filePath) throws IOException {
   StringBuffer fileData = new StringBuffer();
   BufferedReader reader = new BufferedReader(new FileReader(filePath));
   char[] buf = new char[1024];
   int numRead = 0;
   while ((numRead = reader.read(buf)) != -1) {
     String readData = String.valueOf(buf, 0, numRead);
     fileData.append(readData);
   }
   reader.close();
   return fileData.toString();
 }
Пример #10
0
 public String toString() {
   if (isEmpty()) {
     return "";
   }
   StringBuffer sb = new StringBuffer();
   Iterator<NodeLayout> e = nodes.iterator();
   while (e.hasNext()) sb.append((e.next()).toString());
   sb.append("\n");
   Iterator<EdgeLayout> ee = edges.iterator();
   while (ee.hasNext()) sb.append((ee.next()).toString());
   return sb.toString();
 }
Пример #11
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(sourcepid + "," + sourceNode + "," + targetpid + "," + targetNode + ",");
   Iterator<LayoutPoint> e = bends.iterator();
   LayoutPoint b;
   while (e.hasNext()) {
     b = (LayoutPoint) e.next();
     sb.append(b.x + "," + b.y + ",");
   }
   sb.append("\n");
   return sb.toString();
 }
Пример #12
0
    public Element reportDtElem() {
      StringBuffer sb = new StringBuffer(255);
      sb.append(shortTypeName);
      sb.append(" [ dataSourceName: ");
      sb.append(pds.getDataSourceName());
      sb.append("; identityToken: ");
      sb.append(pds.getIdentityToken());
      sb.append(" ]");

      Element dtElem = doc.createElement("dt");
      dtElem.appendChild(doc.createTextNode(sb.toString()));
      return dtElem;
    }
Пример #13
0
 public String toBeautifiedString() {
   StringBuffer sb = new StringBuffer();
   sb.append("sourcePID: " + sourcepid);
   sb.append("  sourceNodeId: " + sourceNode + "\n");
   sb.append("  targetPID: " + targetpid);
   sb.append("  targetNodeId: " + targetNode + "\n");
   Iterator<LayoutPoint> e = bends.iterator();
   LayoutPoint b;
   while (e.hasNext()) {
     b = (LayoutPoint) e.next();
     sb.append(" Bend Points: " + b.x + "," + b.y + "  ");
   }
   sb.append("\n\n");
   return sb.toString();
 }
Пример #14
0
 /**
  * ** Filters an ID String, convertering all letters to lowercase and ** removing invalid
  * characters ** @param text The ID String to filter ** @return The filtered ID String
  */
 public static String FilterID(String text) {
   // ie. "sky.12", "acme@123"
   if (text != null) {
     StringBuffer sb = new StringBuffer();
     for (int i = 0; i < text.length(); i++) {
       char ch = Character.toLowerCase(text.charAt(i));
       if (DBRecordKey.isValidIDChar(ch)) {
         sb.append(ch);
       }
     }
     return sb.toString();
   } else {
     return "";
   }
 }
Пример #15
0
 /**
  * ** Returns a string representation of this object ** @return The string representation of this
  * object
  */
 public String toString() {
   DBField kf[] = this.getKeyFields();
   if (kf.length == 0) {
     return "<null>";
   } else {
     DBFieldValues fv = this.getFieldValues();
     StringBuffer sb = new StringBuffer();
     for (int i = 0; i < kf.length; i++) {
       if (i > 0) {
         sb.append(",");
       }
       sb.append(fv.getFieldValueAsString(kf[i].getName()));
     }
     return sb.toString();
   }
 }
  private void logResultInfo(Query query, String queryResult) {
    StringBuffer sb = new StringBuffer();

    sb.append(
        "\n\n\tQuery "
            + query.getNr()
            + " of run "
            + (query.getQueryMix().getQueryMixRuns() + 1)
            + ":\n");
    sb.append("\n\tQuery string:\n\n");
    sb.append(query.getQueryString());
    sb.append("\n\n\tResult:\n\n");
    sb.append(queryResult);
    sb.append(
        "\n\n__________________________________________________________________________________\n");
    logger.log(Level.ALL, sb.toString());
  }
Пример #17
0
 /* return the value of the XML text node (never null) */
 protected static String GetNodeText(Node root) {
   StringBuffer sb = new StringBuffer();
   if (root != null) {
     NodeList list = root.getChildNodes();
     for (int i = 0; i < list.getLength(); i++) {
       Node n = list.item(i);
       if (n.getNodeType() == Node.CDATA_SECTION_NODE) { // CDATA Section
         sb.append(n.getNodeValue());
       } else if (n.getNodeType() == Node.TEXT_NODE) {
         sb.append(n.getNodeValue());
       } else {
         // Print.logWarn("Unrecognized node type: " + n.getNodeType());
       }
     }
   }
   return sb.toString();
 }
Пример #18
0
  public String toBeautifiedString() {
    StringBuffer sb = new StringBuffer();

    Iterator<NodeLayout> e = nodes.iterator();
    while (e.hasNext()) sb.append((e.next()).toBeautifiedString());
    sb.append("\n");
    Iterator<EdgeLayout> ee = edges.iterator();
    while (ee.hasNext()) {
      sb.append((ee.next()).toBeautifiedString());
    }

    sb.append("\n\nNumber of Nodes: ");
    sb.append(nodes.size());
    sb.append("\nNumber of Edges: ");
    sb.append(edges.size() + "\n");

    return sb.toString();
  }
 /**
  * @param node
  * @param indent
  */
 public static String toString(Node node, int indent) {
   StringBuffer str = new StringBuffer();
   for (int i = 0; i < indent; ++i) str.append("    ");
   str.append(node);
   if (node.hasAttributes()) {
     NamedNodeMap attrs = node.getAttributes();
     for (int j = 0; j < attrs.getLength(); ++j) {
       Node attr = attrs.item(j);
       // str.append(toString(attr,indent+2));
       str.append(" ");
       str.append(attr);
     }
   }
   str.append("\n");
   ++indent;
   for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
     str.append(toString(child, indent));
     // str.append("\n");
   }
   return str.toString();
 }
 // Log the error
 private void log(int level, SAXParseException e) {
   int line = e.getLineNumber();
   int col = e.getColumnNumber();
   String publicId = e.getPublicId();
   String systemId = e.getSystemId();
   StringBuffer sb = new StringBuffer();
   sb.append(e.getMessage());
   if (line > 0 || col > 0) {
     sb.append(": line=");
     sb.append(line);
     sb.append(", col=");
     sb.append(col);
   }
   if (publicId != null || systemId != null) {
     sb.append(": publicId=");
     sb.append(publicId);
     sb.append(", systemId=");
     sb.append(systemId);
   }
   // Log the message
   log.log(level, sb.toString());
 }
Пример #21
0
  private static void showDocument(Document doc) {
    StringBuffer content = new StringBuffer();
    Node node = doc.getChildNodes().item(0);
    ApplicationNode appNode = new ApplicationNode(node);

    content.append("Application \n");

    List<ClassNode> classes = appNode.getClasses();

    for (int i = 0; i < classes.size(); i++) {
      ClassNode classNode = classes.get(i);
      content.append(SPACE + "Class: " + classNode.getName() + " \n");

      List<MethodNode> methods = classNode.getMethods();

      for (int j = 0; j < methods.size(); j++) {
        MethodNode methodNode = methods.get(j);
        content.append(SPACE + SPACE + "Method: " + methodNode.getName() + " \n");
      }
    }

    System.out.println(content.toString());
  }
Пример #22
0
  /**
   * Escape passed string as XML element content (<code>&lt;</code>,
   * <code>&amp;</code> and <code>><code> in <code>]]></code> sequences).
   *
   * @param val a string to be escaped
   *
   * @return escaped value
   * @throws CharConversionException if val contains an improper XML character
   *
   * @since 1.40
   */
  public static String toElementContent(String val) throws CharConversionException {
    if (val == null) throw new CharConversionException("null"); // NOI18N

    if (checkContentCharacters(val)) return val;

    StringBuffer buf = new StringBuffer();

    for (int i = 0; i < val.length(); i++) {
      char ch = val.charAt(i);
      if ('<' == ch) {
        buf.append("&lt;");
        continue;
      } else if ('&' == ch) {
        buf.append("&amp;");
        continue;
      } else if ('>' == ch && i > 1 && val.charAt(i - 2) == ']' && val.charAt(i - 1) == ']') {
        buf.append("&gt;");
        continue;
      }
      buf.append(ch);
    }
    return buf.toString();
  }
Пример #23
0
 private static String FilterID(String id) {
   if (id == null) {
     return null;
   } else {
     StringBuffer newID = new StringBuffer();
     int st = 0;
     for (int i = 0; i < id.length(); i++) {
       char ch = Character.toLowerCase(id.charAt(i));
       if (Character.isLetterOrDigit(ch)) {
         newID.append(ch);
         st = 1;
       } else if (st == 1) {
         newID.append("_");
         st = 0;
       } else {
         // ignore char
       }
     }
     while ((newID.length() > 0) && (newID.charAt(newID.length() - 1) == '_')) {
       newID.setLength(newID.length() - 1);
     }
     return newID.toString();
   }
 }
Пример #24
0
  /**
   * ** Returns a ReverseGeocode instance containing address information ** @param gp The GeoPoint
   * ** @return The ReverseGeocode instance
   */
  private ReverseGeocode getAddressReverseGeocode(GeoPoint gp, String localeStr) {

    /* URL */
    String url = this.getAddressReverseGeocodeURL(gp);
    Print.logInfo("Address URL: " + url);

    /* create XML document */
    Document xmlDoc = GetXMLDocument(url);
    if (xmlDoc == null) {
      return null;
    }

    /* create ReverseGeocode response */
    Element reversegeocode = xmlDoc.getDocumentElement();
    if (!reversegeocode.getTagName().equalsIgnoreCase(TAG_reversegeocode)) {
      return null;
    }

    /* init */
    String address_val = null; // null address
    String house_val = null; // house number
    String road_val = null; // street name
    String city_val = null; // city name
    String county_val = null; // county name
    String state_val = null; // state/province
    String postcode_val = null; // postal code
    String country_name_val = null; // country name
    String country_code_val = null; // country code

    // full address
    NodeList resultList = XMLTools.getChildElements(reversegeocode, TAG_result);
    for (int r = 0; r < resultList.getLength(); r++) {
      Element result = (Element) resultList.item(r);
      // String osmType = XMLTools.getAttribute(result, ATTR_osm_type, null, false);
      address_val = XMLTools.getNodeText(result, " ", false);
      break; // only the first element
    }

    // address components
    NodeList addresspartsList = XMLTools.getChildElements(reversegeocode, TAG_addressparts);
    for (int a = 0; (a < addresspartsList.getLength()); a++) {
      Element addressparts = (Element) addresspartsList.item(a);
      NodeList addresspartsChildren = addressparts.getChildNodes();
      for (int ac = 0; ac < addresspartsChildren.getLength(); ac++) {
        Node child = addresspartsChildren.item(ac);
        if (!(child instanceof Element)) {
          continue;
        }
        Element elem = (Element) child;
        String elemName = elem.getNodeName();
        if (elemName.equalsIgnoreCase(TAG_house)) {
          house_val = XMLTools.getNodeText(elem, " ", false);
        } else if (elemName.equalsIgnoreCase(TAG_tram)) {
          // ignore
        } else if (elemName.equalsIgnoreCase(TAG_road)) {
          road_val = XMLTools.getNodeText(elem, " ", false);
        } else if (elemName.equalsIgnoreCase(TAG_residential)) {
          // ignore
        } else if (elemName.equalsIgnoreCase(TAG_village)) {
          // ignore
        } else if (elemName.equalsIgnoreCase(TAG_town)) {
          if (StringTools.isBlank(city_val)) {
            city_val = XMLTools.getNodeText(elem, " ", false);
          }
        } else if (elemName.equalsIgnoreCase(TAG_city)) {
          city_val = XMLTools.getNodeText(elem, " ", false);
        } else if (elemName.equalsIgnoreCase(TAG_county)) {
          county_val = XMLTools.getNodeText(elem, " ", false);
        } else if (elemName.equalsIgnoreCase(TAG_postcode)) {
          postcode_val = XMLTools.getNodeText(elem, " ", false);
        } else if (elemName.equalsIgnoreCase(TAG_state)) {
          state_val = XMLTools.getNodeText(elem, " ", false);
        } else if (elemName.equalsIgnoreCase(TAG_country)) {
          country_name_val = XMLTools.getNodeText(elem, " ", false);
        } else if (elemName.equalsIgnoreCase(TAG_country_code)) {
          country_code_val = StringTools.trim(XMLTools.getNodeText(elem, " ", false)).toUpperCase();
        } else {
          // elemName unrecognized
        }
      }
      break; // only the first element
    }

    /* populate ReverseGeocode instance */
    ReverseGeocode rg = new ReverseGeocode();
    StringBuffer addr = new StringBuffer();
    // house number /road
    if (!StringTools.isBlank(house_val)) {
      addr.append(house_val);
      if (!StringTools.isBlank(road_val)) {
        addr.append(" ");
        addr.append(road_val);
        rg.setStreetAddress(house_val + " " + road_val);
      } else {
        rg.setStreetAddress(house_val);
      }
    } else if (!StringTools.isBlank(road_val)) {
      addr.append(road_val);
      rg.setStreetAddress(road_val);
    }
    // city/county
    if (!StringTools.isBlank(city_val)) {
      if (addr.length() > 0) {
        addr.append(", ");
      }
      addr.append(city_val);
      rg.setCity(city_val);
    }
    if (!StringTools.isBlank(county_val)) {
      if (StringTools.isBlank(city_val)) {
        // "city" not provided, at least include the "county"
        if (addr.length() > 0) {
          addr.append(", ");
        }
        addr.append("[").append(county_val).append("]");
      }
      // rg.setCounty(county_val);
    }
    // state/province
    if (!StringTools.isBlank(state_val)) {
      if (addr.length() > 0) {
        addr.append(", ");
      }
      addr.append(state_val);
      rg.setStateProvince(state_val);
      if (!StringTools.isBlank(postcode_val)) {
        addr.append(" ").append(postcode_val);
        rg.setPostalCode(postcode_val);
      }
    } else {
      if (!StringTools.isBlank(postcode_val)) {
        if (addr.length() > 0) {
          addr.append(", ");
        }
        addr.append(postcode_val);
        rg.setPostalCode(postcode_val);
      }
    }
    // country
    if (!StringTools.isBlank(country_code_val)) {
      if (country_code_val.equalsIgnoreCase("US")) {
        // if (addr.length() > 0) { addr.append(", "); }
        // addr.append("USA");
      } else if (!StringTools.isBlank(country_name_val)) {
        if (addr.length() > 0) {
          addr.append(", ");
        }
        addr.append(country_name_val);
      } else {
        if (addr.length() > 0) {
          addr.append(", ");
        }
        addr.append(country_code_val);
      }
      rg.setCountryCode(country_code_val);
    }
    // full address
    rg.setFullAddress(addr.toString());

    return rg;
  }
Пример #25
0
  /* encode GeoPoint into nearest address URI */
  protected String getAddressReverseGeocodeURL(GeoPoint gp, String localStr) {
    StringBuffer sb = new StringBuffer();
    GoogleSig sig = this.getSignature();

    /* predefined URL */
    String rgURL = this.getProperties().getString(PROP_reverseGeocodeURL, null);
    if (!StringTools.isBlank(rgURL)) {
      sb.append(rgURL);
      sb.append("&ll=")
          .append(gp.getLatitudeString(GeoPoint.SFORMAT_DEC_5, null))
          .append(",")
          .append(gp.getLongitudeString(GeoPoint.SFORMAT_DEC_5, null));
      String defURL = sb.toString();
      if (sig == null) {
        return defURL;
      } else {
        String urlStr = sig.signURL(defURL);
        return (urlStr != null) ? urlStr : defURL;
      }
    }

    /* assemble URL */
    sb.append(this.getAddressReverseGeocodeURI());
    sb.append("output=xml");
    sb.append("&oe=utf8");

    /* latitude/longitude */
    sb.append("&ll=")
        .append(gp.getLatitudeString(GeoPoint.SFORMAT_DEC_5, null))
        .append(",")
        .append(gp.getLongitudeString(GeoPoint.SFORMAT_DEC_5, null));

    /* sensor */
    String sensor = this.getProperties().getString(PROP_sensor, null);
    if (!StringTools.isBlank(sensor)) {
      sb.append("&sensor=").append(sensor);
    }

    /* key */
    String channel = this.getProperties().getString(PROP_channel, null);
    String auth = this.getAuthorization();
    if (StringTools.isBlank(auth) || auth.startsWith("*")) {
      // invalid key
    } else if (auth.startsWith(CLIENT_ID_PREFIX)) {
      sb.append("&client=").append(auth);
      if (StringTools.isBlank(channel)) {
        channel = DBConfig.getServiceAccountID(null);
      }
    } else {
      sb.append("&key=").append(auth);
    }

    /* channel */
    if (!StringTools.isBlank(channel)) {
      sb.append("&channel=").append(channel);
    }

    /* localization ("&hl=") */
    if (!StringTools.isBlank(localStr)) {
      sb.append("&hl=").append(localStr);
    }

    /* return url */
    String defURL = sb.toString();
    if (sig == null) {
      return defURL;
    } else {
      String urlStr = sig.signURL(defURL);
      return (urlStr != null) ? urlStr : defURL;
    }
  }
Пример #26
0
  /* encode GeoPoint into nearest address URI */
  protected String getGeoPointGeocodeURL(String address, String country) {
    StringBuffer sb = new StringBuffer();
    GoogleSig sig = this.getSignature();

    /* country */
    if (StringTools.isBlank(country)) {
      country = this.getProperties().getString(PROP_countryCodeBias, DEFAULT_COUNTRY);
    }

    /* predefined URL */
    String gcURL = this.getProperties().getString(PROP_geocodeURL, null);
    if (!StringTools.isBlank(gcURL)) {
      sb.append(gcURL);
      sb.append("&q=").append(URIArg.encodeArg(address));
      if (!StringTools.isBlank(country)) {
        // country code bias: http://en.wikipedia.org/wiki/CcTLD
        sb.append("&gl=").append(country);
      }
      return sb.toString();
    }

    /* assemble URL */
    sb.append(this.getGeoPointGeocodeURI());
    sb.append("output=xml");
    sb.append("&oe=utf8");

    /* address/country */
    sb.append("&q=").append(URIArg.encodeArg(address));
    if (!StringTools.isBlank(country)) {
      sb.append("&gl=").append(country);
    }

    /* sensor */
    String sensor = this.getProperties().getString(PROP_sensor, null);
    if (!StringTools.isBlank(sensor)) {
      sb.append("&sensor=").append(sensor);
    }

    /* channel */
    String channel = this.getProperties().getString(PROP_channel, null);
    if (!StringTools.isBlank(channel)) {
      sb.append("&channel=").append(channel);
    }

    /* key */
    String auth = this.getAuthorization();
    if (StringTools.isBlank(auth) || auth.startsWith("*")) {
      // invalid key
    } else if (auth.startsWith(CLIENT_ID_PREFIX)) {
      sb.append("&client=").append(auth);
    } else {
      sb.append("&key=").append(auth);
    }

    /* return url */
    String defURL = sb.toString();
    if (sig == null) {
      return defURL;
    } else {
      String urlStr = sig.signURL(defURL);
      return (urlStr != null) ? urlStr : defURL;
    }
  }