List of usage examples for java.net MalformedURLException MalformedURLException
public MalformedURLException(String msg)
From source file:com.knowgate.dfs.FileSystem.java
/** * Read a serializable object from a text file * @param sFilePath Full file path. For example "file:///tmp/myfile.bin" or "ftp://localhost:21/tmp/myfile.bin" * @throws MalformedURLException if sFilePath does not begin with file://or ftp:// * @throws ClassNotFoundException/*w w w . ja v a 2 s . c o m*/ * @throws FileNotFoundException * @throws IOException * @since 4.0 */ public Object readfileobj(String sFilePath) throws MalformedURLException, FileNotFoundException, IOException, FTPException, ClassNotFoundException { Object oRetVal; ObjectInputStream oObjStrm; String sLower = sFilePath.toLowerCase(); if (sLower.startsWith("file://")) { sFilePath = sFilePath.substring(7); FileInputStream oInStrm = new FileInputStream(sFilePath); oObjStrm = new ObjectInputStream(oInStrm); oRetVal = oObjStrm.readObject(); oObjStrm.close(); oInStrm.close(); } else if (sLower.startsWith("ftp://")) { byte[] aFileBytes = readfilebin(sFilePath); ByteArrayInputStream oBteStrm = new ByteArrayInputStream(aFileBytes); oObjStrm = new ObjectInputStream(oBteStrm); oRetVal = oObjStrm.readObject(); oObjStrm.close(); oBteStrm.close(); } else { throw new MalformedURLException( "FileSystem.readfileobj(" + sFilePath + ") File protocol must begin with file:// or ftp://"); } return oRetVal; }
From source file:lucee.runtime.tag.Http.java
/** * merge to pathes to one/* w w w .ja va2s . c o m*/ * * @param current * @param realPath * @return * @throws MalformedURLException */ public static String mergePath(String current, String realPath) throws MalformedURLException { // get current directory String currDir; if (current == null || current.indexOf('/') == -1) currDir = "/"; else if (current.endsWith("/")) currDir = current; else currDir = current.substring(0, current.lastIndexOf('/') + 1); // merge together String path; if (realPath.startsWith("./")) path = currDir + realPath.substring(2); else if (realPath.startsWith("/")) path = realPath; else if (!realPath.startsWith("../")) path = currDir + realPath; else { while (realPath.startsWith("../") || currDir.length() == 0) { realPath = realPath.substring(3); currDir = currDir.substring(0, currDir.length() - 1); int index = currDir.lastIndexOf('/'); if (index == -1) throw new MalformedURLException("invalid realpath definition for URL"); currDir = currDir.substring(0, index + 1); } path = currDir + realPath; } return path; }
From source file:com.ucuenca.pentaho.plugin.step.EldaPDIStepDialog.java
public ArrayList ConsultarFuseki(String Servicio) { ArrayList<String> mili = new ArrayList<String>(); String queryString = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" + " select distinct ?object " + "FROM <" + wTextBaseUri.getText().trim() + ">" + " WHERE {" + " ?s rdf:type ?object " + " } LIMIT 100 "; if (wTextBaseUri.getText().trim().isEmpty()) { //si esta vacio busco sin graph queryString = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" + " select distinct ?object " + " WHERE {" + " ?s rdf:type ?object " + " } LIMIT 100 "; }//from w ww . j a va 2 s . c om // now creating query object Query query = QueryFactory.create(queryString); // http://localhost:3030/myservice/query // **this actually was the main problem I couldn't figure out.** //QueryExecution qexec = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query); //QueryExecution qexec = QueryExecutionFactory.sparqlService("http://localhost:3030/myservice/query", query); //QueryExecution qexec = QueryExecutionFactory.sparqlService("http://localhost:3030/#myds/sparql", query); //ocalhost:3030/myservice/query?query //qexec = QueryExecutionFactory.sparqlService("http://localhost:3030/sparql.tpl", query); QueryExecution qexec = QueryExecutionFactory.sparqlService(Servicio, query); //after it goes standard query execution and result processing which can // be found in almost any Jena/SPARQL tutorial. System.out.println(" servicio " + Servicio + "query " + query); try { ResultSet results = qexec.execSelect(); ArrayList<QuerySolution> solutions = new ArrayList<QuerySolution>(); solutions = (ArrayList<QuerySolution>) ResultSetFormatter.toList(results); solutions.toArray(); // Output query results ResultSetFormatter.out(System.out, results, query); if (solutions.size() > 0) { // validacion lista vacia solutions.get(0).get("?object"); System.out.println("accediendo fuseki entro antes for"); for (int i = 0; i < solutions.size(); i++) { mili.add(solutions.get(i).get("?object").toString()); System.out.println("accediendo fuseki entro " + solutions.get(i).get("?object").toString()); } } //-------public RepositorySpace obtainRepositorySpace(final String repositorySpaceURL) throws XMLException, IOException, MalformedURLException { throw new MalformedURLException("s"); } catch (MalformedURLException d) { logBasic(" ERROR " + d.getMessage() + "BAD url"); } finally { qexec.close(); } //after it goes standard query execution and result processing which can // be found in almost any Jena/SPARQL tutorial. /* try { ResultSet results = qexec.execSelect(); for (; results.hasNext();) { // Result processing is done here. } } finally { qexec.close(); }*/ return mili; }
From source file:com.ucuenca.pentaho.plugin.step.EldaPDIStepDialog.java
/** * Metodo para obtener todas las propiedades del endPoint * @param Servicio//www .j a v a 2 s . c o m * @return */ public ArrayList ConsultarFusekiPropiedades(String Servicio) { ArrayList<String> mili = new ArrayList<String>(); String queryString = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " + " SELECT DISTINCT ?pred WHERE { ?pred a rdf:Property } ORDER BY ?pred " + " LIMIT 100 "; // now creating query object Query query = QueryFactory.create(queryString); //QueryExecution qexec = QueryExecutionFactory.sparqlService("http://localhost:3030/myservice/query", query); QueryExecution qexec = QueryExecutionFactory.sparqlService(Servicio, query); //after it goes standard query execution and result processing which can // be found in almost any Jena/SPARQL tutorial. System.out.println("accediendo fuseki "); try { ResultSet results = qexec.execSelect(); ArrayList<QuerySolution> solutions = new ArrayList<QuerySolution>(); solutions = (ArrayList<QuerySolution>) ResultSetFormatter.toList(results); solutions.toArray(); // Output query results ResultSetFormatter.out(System.out, results, query); if (solutions.size() > 0) { // validacion lista vacia solutions.get(0).get("?pred"); System.out.println("accediendo fuseki entro antes for"); for (int i = 0; i < solutions.size(); i++) { mili.add(solutions.get(i).get("?pred").toString()); System.out .println("accediendo servicio propiedades " + solutions.get(i).get("?pred").toString()); } } //------- throw new MalformedURLException("s"); } catch (MalformedURLException d) { logBasic("Query Entidades " + d.getMessage() + " try"); } finally { qexec.close(); } return mili; }
From source file:focusedCrawler.util.parser.PaginaURL.java
/** * Declara\uFFFD\uFFFDo do M\uFFFDtodo//from w w w . j a v a 2s .com * * * @param base * @param link * * @return * * @throws MalformedURLException * * @see */ protected URL parseLink(URL base, String link) throws MalformedURLException { String original = link; int i, limit, c; int start = 0; String newProtocol = null; boolean aRef = false; String protocol = null; String host = null; int port = -1; String file = null; String ref = null; try { limit = link.length(); while ((limit > 0) && (link.charAt(limit - 1) <= ' ')) { limit--; // eliminate trailing whitespace } while ((start < limit) && (link.charAt(start) <= ' ')) { start++; // eliminate leading whitespace } if (link.regionMatches(true, start, "url:", 0, 4)) { start += 4; } if (start < link.length() && link.charAt(start) == '#') { /* * we're assuming this is a ref relative to the context URL. * This means protocols cannot start w/ '#', but we must parse * ref URL's like: "hello:there" w/ a ':' in them. */ aRef = true; } for (i = start; !aRef && (i < limit) && ((c = link.charAt(i)) != '/'); i++) { if (c == ':') { newProtocol = link.substring(start, i).toLowerCase(); start = i + 1; break; } } // Only use our context if the protocols match. if ((base != null) && ((newProtocol == null) || newProtocol.equals(base.getProtocol()))) { protocol = base.getProtocol(); host = base.getHost(); port = base.getPort(); file = base.getFile(); } else { protocol = newProtocol; } if (protocol == null) { throw new MalformedURLException("no protocol: " + original); } // if ((handler = getURLStreamHandler(protocol)) == null) { // throw new MalformedURLException("unknown protocol: "+protocol); // } i = link.indexOf('#', start); if (i >= 0) { ref = link.substring(i + 1, limit); limit = i; } // if ("http".equals(protocol)) return parseURL(protocol, host, port, file, ref, link, start, limit); if ("http".equals(protocol)) { return parseURL(protocol, host, port, file, null, link, start, limit); } else { return new URL(base, link); } } catch (MalformedURLException e) { throw e; } catch (Exception e) { throw new MalformedURLException(original + ": " + e); } }
From source file:de.innovationgate.utils.WGUtils.java
/** * Decodes an encoded URI sequence according to the given charset * This is able to decode URL-encoded characters but also leaves existing Non-ASCII characters intact (unlike Common HttpClients URIUtil) * @param uriCharSequence The URI sequence * @param charset The charset used to decode * @return The decoded string//from ww w.ja v a 2 s . co m * @throws UnsupportedEncodingException * @throws MalformedURLException */ public static String decodeURI(CharSequence uriCharSequence, String charset) throws UnsupportedEncodingException, MalformedURLException { if (uriCharSequence == null) { return null; } String uri = uriCharSequence.toString(); int oi = 0; // output index ByteArrayOutputStream out = new ByteArrayOutputStream(); for (int i = 0; i < uri.length(); i++) { char c = uri.charAt(i); if (c == '%' && i + 2 <= uri.length()) { byte high = (byte) Character.digit((char) uri.charAt(++i), 16); byte low = (byte) Character.digit((char) uri.charAt(++i), 16); if (high == -1 || low == -1) { throw new MalformedURLException("Invalid escape pattern"); } byte aByte = (byte) ((high << 4) + low); out.write(aByte); } else if (c == '+') { out.write(' '); } else { byte[] bytes = String.valueOf(c).getBytes(charset); out.write(bytes, 0, bytes.length); } } return out.toString(charset); }