List of usage examples for java.lang String isEmpty
public boolean isEmpty()
From source file:com.galenframework.parser.Expectations.java
public static List<String> readAllWords(String arguments) { List<String> words = new LinkedList<String>(); StringCharReader reader = new StringCharReader(arguments); ExpectWord expectWord = new ExpectWord(); while (reader.hasMoreNormalSymbols()) { String word = expectWord.read(reader); if (!word.isEmpty()) { words.add(word);//w w w .j a v a2s .co m } } return words; }
From source file:hr.fer.spocc.export.DotExporter.java
public static String toDotString(ParseTree parseTree, String graphName) { Validate.isTrue(!graphName.isEmpty() && StringUtils.isAlphanumeric(graphName) && Character.isLetter(graphName.charAt(0))); StringBuilder dotString = new StringBuilder(); dotString.append("digraph ").append(graphName).append(" {\n"); Map<ParseTreeNode, String> nodePrefixMap = new LinkedHashMap<ParseTreeNode, String>(); toDotNodes(parseTree.getRoot(), new StringBuilder(), nodePrefixMap, dotString); toDotEdges(parseTree.getRoot(), nodePrefixMap, dotString); dotString.append("}\n"); return dotString.toString(); }
From source file:io.teak.sdk.DebugConfiguration.java
@SuppressWarnings("unused") public static void addExternalDebugInfo(String key, Object value) { if (key == null || key.isEmpty()) { Log.e(LOG_TAG, "key can not be null or empty for addExternalDebugInfo(), ignoring."); return;//from ww w . j a v a 2 s .c om } try { if (value == null || value.toString() == null || value.toString().isEmpty()) { Log.e(LOG_TAG, "value can not be null or empty for addExternalDebugInfo(), ignoring."); return; } } catch (Exception e) { Log.e(LOG_TAG, "Error occured while converting value to string in addExternalDebugInfo(), ignoring."); return; } DebugConfiguration.externalDebugInfo.put(key, value); }
From source file:Main.java
public static byte[] encryptMsg(String msg, RSAPublicKeySpec pubKeySpec) { if (msg != null && pubKeySpec != null && !msg.isEmpty()) { try {/*from w w w. ja va 2 s . c o m*/ Log.w(TAG, "msg is: " + msg + " with length " + msg.length()); KeyFactory fact = KeyFactory.getInstance("RSA"); PublicKey pubKey = fact.generatePublic(pubKeySpec); // TODO encrypt the message and send it // Cipher cipher = Cipher.getInstance("RSA/None/NoPadding"); Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); // Cipher cipher = // Cipher.getInstance("RSA/None/OAEPWithSHA1AndMGF1Padding", // "BC"); cipher.init(Cipher.ENCRYPT_MODE, pubKey); Log.d(TAG, "cipher block size is " + cipher.getBlockSize()); byte[] msgByteArray = msg.getBytes(); byte[] cipherData = new byte[cipher.getOutputSize(msgByteArray.length)]; cipherData = cipher.doFinal(msgByteArray); Log.d(TAG, "output size is " + cipher.getOutputSize(msgByteArray.length)); Log.d(TAG, "is the measurement already broken into chunks here? " + (new String(cipherData))); return cipherData; } catch (NoSuchAlgorithmException e) { Log.e(TAG, "RSA algorithm not available", e); } catch (InvalidKeySpecException e) { Log.e(TAG, "", e); } catch (NoSuchPaddingException e) { Log.e(TAG, "", e); } catch (InvalidKeyException e) { Log.e(TAG, "", e); } catch (BadPaddingException e) { Log.e(TAG, "", e); } catch (IllegalBlockSizeException e) { Log.e(TAG, "", e); } catch (Exception e) { Log.e(TAG, "", e); } /* * catch (NoSuchProviderException e) { Log.e(TAG, "", e); } */ } return null; }
From source file:com.atypon.wayf.request.RequestReader.java
public static String readRequiredPathParameter(RoutingContext routingContext, String argumentName, String argDescription) {//from w ww .ja va2 s .com String parameter = readPathArgument(routingContext, argumentName); if (parameter == null || parameter.isEmpty()) { throw new ServiceException(HttpStatus.SC_BAD_REQUEST, argDescription + " is a required URL parameter"); } return parameter; }
From source file:at.uni_salzburg.cs.ckgroup.cscpp.mapper.registry.RegistryPersistence.java
@SuppressWarnings("unchecked") public static void loadRegistry(File registryFile, Map<String, IRegistrationData> registrationData) throws IOException { synchronized (lock) { String reg = FileUtils.loadFileAsString(registryFile); if (reg == null || reg.isEmpty()) { LOG.info("Can not load registry, because of empty or missing file " + registryFile); return; }/* www . j a v a2s . c om*/ List<Object> list; try { list = (List<Object>) parser.parse(reg); } catch (ParseException e) { throw new IOException("Parsing " + registryFile.getAbsolutePath() + " failed", e); } int counter = 0; for (Object entry : list) { RegData rd = new RegData((JSONObject) entry); registrationData.put(rd.getEngineUrl(), rd); ++counter; } LOG.info(counter + " Registry entries successfully loaded from file " + registryFile); } }
From source file:mServer.tool.MserverDatumZeit.java
public static String getNameAkt(String path) { // liefert den Namen der Filmliste "akt" von heute if (path.isEmpty()) { return ""; }/*from w w w . j av a 2 s . c om*/ return Functions.addsPfad(path, "Filmliste-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xz"); }
From source file:nl.dtls.fairdatapoint.api.controller.utils.HttpHeadersUtils.java
public static RDFFormat getRequestedAcceptHeader(String contentType) { RDFFormat requesetedContentType = null; if (contentType == null || contentType.isEmpty()) { requesetedContentType = RDFFormat.TURTLE; } else if (contentType.contentEquals(RDFFormat.TURTLE.getDefaultMIMEType()) || contentType.contains(MediaType.ALL_VALUE)) { requesetedContentType = RDFFormat.TURTLE; } else if (contentType.contentEquals(RDFFormat.JSONLD.getDefaultMIMEType())) { requesetedContentType = RDFFormat.JSONLD; } else if (contentType.contentEquals(RDFFormat.N3.getDefaultMIMEType())) { requesetedContentType = RDFFormat.N3; } else if (contentType.contentEquals(RDFFormat.RDFXML.getDefaultMIMEType())) { requesetedContentType = RDFFormat.RDFXML; }/*from www .ja va 2 s . c o m*/ return requesetedContentType; }
From source file:msuresh.raftdistdb.RaftClient.java
public static void GetValue(String name, String key) throws FileNotFoundException { if (key == null || key.isEmpty()) { return;/*from w w w . ja v a 2s . c o m*/ } File configFile = new File(Constants.STATE_LOCATION + name + ".info"); if (!configFile.exists() || configFile.isDirectory()) { FileNotFoundException ex = new FileNotFoundException(); throw ex; } try { System.out.println("Getting key .. Hold on."); String content = new Scanner(configFile).useDelimiter("\\Z").next(); JSONObject config = (JSONObject) (new JSONParser()).parse(content); Long numPart = (Long) config.get("countPartitions"); Integer shardId = key.hashCode() % numPart.intValue(); JSONArray memberJson = (JSONArray) config.get(shardId.toString()); List<Address> members = new ArrayList<>(); for (int i = 0; i < memberJson.size(); i++) { JSONObject obj = (JSONObject) memberJson.get(i); Long port = (Long) obj.get("port"); String address = (String) obj.get("address"); members.add(new Address(address, port.intValue())); } CopycatClient client = CopycatClient.builder(members).withTransport(new NettyTransport()).build(); client.open().join(); Object str = client.submit(new GetQuery(key)).get(); System.out.println("For the key : " + key + ", the database returned the value : " + (String) str); client.close().join(); while (client.isOpen()) { Thread.sleep(1000); } } catch (Exception ex) { System.out.println(ex.toString()); } }
From source file:jackrabbit.repository.RepositoryManager.java
public static void registerCustomNodeTypes(Session session, String cndPath) throws IOException, RepositoryException, ParseException { if (cndPath == null || cndPath.isEmpty()) { log.error("CND path is null or empty."); return;//from ww w . ja va 2 s.co m } NamespaceRegistry registry = session.getWorkspace().getNamespaceRegistry(); List<String> prefixes = Arrays.asList(registry.getPrefixes()); if (!prefixes.contains("fsp")) registry.registerNamespace("fsp", "http://www.findlaw.com/jcr/fsp"); if (!prefixes.contains("prop")) registry.registerNamespace("prop", "http://www.findlaw.com/jcr/fsp/prop"); CndImporter.registerNodeTypes(new FileReader(cndPath), session); }