Package java.net

Examples of java.net.URISyntaxException


        String result = null;
        URI uri = new URI(sftpURI);
        result = uri.getPath();

        if (result == null) {
            throw new URISyntaxException(sftpURI, "Missing path in URI.");
        }

        return result;
    }
View Full Code Here


            {
                getInfoFromAddress();
            }
            catch(Exception e)
            {
                URISyntaxException ex = new URISyntaxException(str,"Error parsing address");
                ex.initCause(e);
                throw ex;
            }
        }
        _logger.debug("Based on " + str + " the selected destination syntax is " + _destSyntax);
    }
View Full Code Here

        {
            URI connection = new URI(fullURL);

            if ((connection.getScheme() == null) || !(connection.getScheme().equalsIgnoreCase(AMQConnectionURL.AMQ_PROTOCOL)))
            {
                throw new URISyntaxException(fullURL, "Not an AMQP URL");
            }

            if ((connection.getHost() == null) || connection.getHost().equals(""))
            {
                String tmp = connection.getAuthority();
View Full Code Here

            throw new IllegalArgumentException("unrecognized elasticsearch protocol: " + protocol + " for uri: " + uri);
        }
        setUri(uri);
        setAuthority(uri.getAuthority());
        if (!isValidAuthority()) {
            throw new URISyntaxException(uri.toASCIIString(), "incorrect URI syntax specified for the elasticsearch endpoint."
                                                              + "please specify the syntax as \"elasticsearch:[Cluster Name | 'local']?[Query]\"");
        }

        if (LOCAL_NAME.equals(getAuthority())) {
            setLocal(true);
View Full Code Here

     * @see #RAW_TOKEN_END
     */
    public static Map<String, Object> parseQuery(String uri, boolean useRaw) throws URISyntaxException {
        // must check for trailing & as the uri.split("&") will ignore those
        if (uri != null && uri.endsWith("&")) {
            throw new URISyntaxException(uri, "Invalid uri syntax: Trailing & marker found. "
                    + "Check the uri and remove the trailing & marker.");
        }

        if (ObjectHelper.isEmpty(uri)) {
            // return an empty map
            return new LinkedHashMap<String, Object>(0);
        }

        // need to parse the uri query parameters manually as we cannot rely on splitting by &,
        // as & can be used in a parameter value as well.

        try {
            // use a linked map so the parameters is in the same order
            Map<String, Object> rc = new LinkedHashMap<String, Object>();

            boolean isKey = true;
            boolean isValue = false;
            boolean isRaw = false;
            StringBuilder key = new StringBuilder();
            StringBuilder value = new StringBuilder();

            // parse the uri parameters char by char
            for (int i = 0; i < uri.length(); i++) {
                // current char
                char ch = uri.charAt(i);
                // look ahead of the next char
                char next;
                if (i < uri.length() - 2) {
                    next = uri.charAt(i + 1);
                } else {
                    next = '\u0000';
                }

                // are we a raw value
                isRaw = value.toString().startsWith(RAW_TOKEN_START);

                // if we are in raw mode, then we keep adding until we hit the end marker
                if (isRaw) {
                    if (isKey) {
                        key.append(ch);
                    } else if (isValue) {
                        value.append(ch);
                    }

                    // we only end the raw marker if its )& or at the end of the value

                    boolean end = ch == RAW_TOKEN_END.charAt(0) && (next == '&' || next == '\u0000');
                    if (end) {
                        // raw value end, so add that as a parameter, and reset flags
                        addParameter(key.toString(), value.toString(), rc, useRaw || isRaw);
                        key.setLength(0);
                        value.setLength(0);
                        isKey = true;
                        isValue = false;
                        isRaw = false;
                        // skip to next as we are in raw mode and have already added the value
                        i++;
                    }
                    continue;
                }

                // if its a key and there is a = sign then the key ends and we are in value mode
                if (isKey && ch == '=') {
                    isKey = false;
                    isValue = true;
                    isRaw = false;
                    continue;
                }

                // the & denote parameter is ended
                if (ch == '&') {
                    // parameter is ended, as we hit & separator
                    addParameter(key.toString(), value.toString(), rc, useRaw || isRaw);
                    key.setLength(0);
                    value.setLength(0);
                    isKey = true;
                    isValue = false;
                    isRaw = false;
                    continue;
                }

                // regular char so add it to the key or value
                if (isKey) {
                    key.append(ch);
                } else if (isValue) {
                    value.append(ch);
                }
            }

            // any left over parameters, then add that
            if (key.length() > 0) {
                addParameter(key.toString(), value.toString(), rc, useRaw || isRaw);
            }

            return rc;

        } catch (UnsupportedEncodingException e) {
            URISyntaxException se = new URISyntaxException(e.toString(), "Invalid encoding");
            se.initCause(e);
            throw se;
        }
    }
View Full Code Here

                return rc.toString();
            } else {
                return "";
            }
        } catch (UnsupportedEncodingException e) {
            URISyntaxException se = new URISyntaxException(e.toString(), "Invalid encoding");
            se.initCause(e);
            throw se;
        }
    }
View Full Code Here

   * @param s
   * @throws URISyntaxException
   */
  public URIish(String s) throws URISyntaxException {
    if (StringUtils.isEmptyOrNull(s)) {
      throw new URISyntaxException("The uri was empty or null",
          JGitText.get().cannotParseGitURIish);
    }
    Matcher matcher = SINGLE_SLASH_FILE_URI.matcher(s);
    if (matcher.matches()) {
      scheme = matcher.group(1);
      rawPath = cleanLeadingSlashes(matcher.group(2), scheme);
      path = unescape(rawPath);
      return;
    }
    matcher = FULL_URI.matcher(s);
    if (matcher.matches()) {
      scheme = matcher.group(1);
      user = unescape(matcher.group(2));
      pass = unescape(matcher.group(3));
      host = unescape(matcher.group(4));
      if (matcher.group(5) != null)
        port = Integer.parseInt(matcher.group(5));
      rawPath = cleanLeadingSlashes(
          n2e(matcher.group(6)) + n2e(matcher.group(7)), scheme);
      path = unescape(rawPath);
      return;
    }
    matcher = RELATIVE_SCP_URI.matcher(s);
    if (matcher.matches()) {
      user = matcher.group(1);
      pass = matcher.group(2);
      host = matcher.group(3);
      rawPath = matcher.group(4);
      path = rawPath;
      return;
    }
    matcher = ABSOLUTE_SCP_URI.matcher(s);
    if (matcher.matches()) {
      user = matcher.group(1);
      pass = matcher.group(2);
      host = matcher.group(3);
      rawPath = matcher.group(4);
      path = rawPath;
      return;
    }
    matcher = LOCAL_FILE.matcher(s);
    if (matcher.matches()) {
      rawPath = matcher.group(1);
      path = rawPath;
      return;
    }
    throw new URISyntaxException(s, JGitText.get().cannotParseGitURIish);
  }
View Full Code Here

    int j = 0;
    for (int i = 0; i < bytes.length; ++i) {
      byte c = bytes[i];
      if (c == '%') {
        if (i + 2 >= bytes.length)
          throw new URISyntaxException(s, JGitText.get().cannotParseGitURIish);
        int val = (RawParseUtils.parseHexInt4(bytes[i + 1]) << 4)
            | RawParseUtils.parseHexInt4(bytes[i + 2]);
        os[j++] = (byte) val;
        i += 2;
      } else
View Full Code Here

         if (entryURL == null)
            entryURL = new URL(jarURL, getName());
      }
      catch (MalformedURLException e)
      {
         throw new URISyntaxException("Failed to create relative jarURL", e.getMessage());
      }
      return entryURL.toURI();
   }
View Full Code Here

            // app path could be a directory
            Path path = new Path(uri.getPath());
            // check file exists for dataset include file, app xml already checked
            if (!fs.exists(path)) {
                throw new URISyntaxException(path.toString(), "path not existed : " + path.toString());
            }
            if (!fs.isFile(path)) {
                appDefPath = new Path(path, COORDINATOR_XML_FILE);
            } else {
                appDefPath = path;
View Full Code Here

TOP

Related Classes of java.net.URISyntaxException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.