/** * @param value String value to test * @return true if value is null or empty trimmed */ protected static boolean isNullOrEmptyTrimmed(String value) { return JOrphanUtils.isBlank(value); } }
/** * Is a dynamic proxy defined? * * @param proxyHost the host to check * @param proxyPort the port to check * @return {@code true} iff both ProxyPort and ProxyHost are defined. */ protected boolean isDynamicProxy(String proxyHost, int proxyPort){ return !JOrphanUtils.isBlank(proxyHost) && proxyPort > 0; }
/** * * @param attribute Attribute to extract * @param element Element * @return String value */ private String extractValue(String attribute, Element element) { if (!JOrphanUtils.isBlank(attribute)) { return element.attr(attribute); } else { return element.text().trim(); } } }
private BufferedWriter createBufferedWriter(FileEntry fileEntry) throws IOException { FileOutputStream fos = new FileOutputStream(fileEntry.file); OutputStreamWriter osw; // If file encoding is specified, write using that encoding, otherwise use default platform encoding String charsetName = fileEntry.charSetEncoding; if(!JOrphanUtils.isBlank(charsetName)) { osw = new OutputStreamWriter(fos, charsetName); } else { osw = new OutputStreamWriter(fos); } return new BufferedWriter(osw); }
/** * Is this parameter skippable, i.e. empty/blank string * or it looks like an unrecognised variable. * * @param parameterName - parameter name * @return true if parameter should be skipped */ public boolean isSkippable(String parameterName) { if (JOrphanUtils.isBlank(parameterName)){ return true; // Skip parameters with a blank name (allows use of optional variables in parameter lists) } // TODO: improve this test if (parameterName.trim().startsWith("${") && parameterName.endsWith("}")){// $NON-NLS-1$ $NON-NLS-2$ return true; // Missing variable name } return false; }
private BufferedReader createBufferedReader(FileEntry fileEntry) throws IOException { if (!fileEntry.file.canRead() || !fileEntry.file.isFile()) { throw new IllegalArgumentException("File "+ fileEntry.file.getName()+ " must exist and be readable"); } FileInputStream fis = new FileInputStream(fileEntry.file); InputStreamReader isr = null; // If file encoding is specified, read using that encoding, otherwise use default platform encoding String charsetName = fileEntry.charSetEncoding; if(!JOrphanUtils.isBlank(charsetName)) { isr = new InputStreamReader(fis, charsetName); } else { isr = new InputStreamReader(fis); } return new BufferedReader(isr); }
public int[] getMatchNumbersAsInt(int arraySize) { String matchNumbersAsString = getMatchNumbers(); int[] result = new int[arraySize]; if (JOrphanUtils.isBlank(matchNumbersAsString)) { Arrays.fill(result, 0); } else { String[] matchNumbersAsStringArray = matchNumbersAsString.split(SEPARATOR); for (int i = 0; i < matchNumbersAsStringArray.length; i++) { result[i] = Integer.parseInt(matchNumbersAsStringArray[i].trim()); } } return result; } }
private String extractValue(String attribute, Node element) { if (!JOrphanUtils.isBlank(attribute)) { return element.getAttribute(attribute); } else { return element.getTextContent().trim(); } } }
public static HTTPAbstractImpl getImplementation(String impl, HTTPSamplerBase base){ if (HTTPSamplerBase.PROTOCOL_FILE.equals(base.getProtocol())) { return new HTTPFileImpl(base); } if (JOrphanUtils.isBlank(impl)){ impl = DEFAULT_CLASSNAME; } if (IMPL_JAVA.equals(impl) || HTTP_SAMPLER_JAVA.equals(impl)) { return new HTTPJavaImpl(base); } else if (IMPL_HTTP_CLIENT4.equals(impl) || IMPL_HTTP_CLIENT3_1.equals(impl)) { return new HTTPHC4Impl(base); } else { throw new IllegalArgumentException("Unknown implementation type: '"+impl+"'"); } }
while ((line = reader.readLine()) != null) { try { if (line.startsWith("#") || JOrphanUtils.isBlank(line)) {// $NON-NLS-1$ continue;
while ((line = reader.readLine()) != null) { try { if (line.startsWith("#") || JOrphanUtils.isBlank(line)) {//$NON-NLS-1$ continue;
while ((line = reader.readLine()) != null) { try { if (line.startsWith("#") || JOrphanUtils.isBlank(line)) { //$NON-NLS-1$ continue;
/** * Calls the JDBC code to be executed. */ protected void process() { if(JOrphanUtils.isBlank(getDataSource())) { throw new IllegalArgumentException("Variable Name must not be null in "+getName()); } try (Connection conn = DataSourceElement.getConnection(getDataSource())){ execute(conn); } catch (SQLException ex) { log.warn("SQL Problem in {}: {}", getName(), ex.toString()); } catch (IOException ex) { log.warn("IO Problem in {}: {}"+ getName(), ex.toString()); } catch (UnsupportedOperationException ex) { log.warn("Execution Problem in {}: {}", getName(), ex.toString()); } }
public String getQueryString(String contentEncoding) { if (JOrphanUtils.isBlank(contentEncoding)) {
public String getQueryString(String contentEncoding) { if(JOrphanUtils.isBlank(contentEncoding)) {
if(!JOrphanUtils.isBlank(this.port)) { port = Integer.parseInt(this.port); if(!JOrphanUtils.isBlank(this.timeout)) { timeout = Integer.parseInt(this.timeout); if(!JOrphanUtils.isBlank(this.database)) { database = Integer.parseInt(this.database); if(!JOrphanUtils.isBlank(this.password)) { password = this.password;
@Override public void testStarted() { this.setRunningVersion(true); TestBeanHelper.prepare(this); JMeterVariables variables = getThreadContext().getVariables(); String poolName = getDataSource(); if(JOrphanUtils.isBlank(poolName)) { throw new IllegalArgumentException("Variable Name must not be empty for element:"+getName()); } else if (variables.getObject(poolName) != null) { log.error("JDBC data source already defined for: {}", poolName); } else { String maxPool = getPoolMax(); perThreadPoolSet = Collections.synchronizedSet(new HashSet<BasicDataSource>()); if (maxPool.equals("0")){ // i.e. if we want per thread pooling variables.putObject(poolName, new DataSourceComponentImpl()); // pool will be created later } else { BasicDataSource src = initPool(maxPool); synchronized(this){ dbcpDataSource = src; variables.putObject(poolName, new DataSourceComponentImpl(dbcpDataSource)); } } } }
if(!JOrphanUtils.isBlank(this.port)) { port = Integer.parseInt(this.port); if(!JOrphanUtils.isBlank(this.timeout)) { timeout = Integer.parseInt(this.timeout); if(!JOrphanUtils.isBlank(this.database)) { database = Integer.parseInt(this.database); if(!JOrphanUtils.isBlank(this.password)) { password = this.password;
if(JOrphanUtils.isBlank(getDataSource())) { throw new IllegalArgumentException("Variable Name must not be null in "+getName());
JMeterTreeNode node = (JMeterTreeNode) value; super.getTreeCellRendererComponent(tree, JOrphanUtils.isBlank(node.getName()) ? BLANK : node.getName(), sel, expanded, leaf, row, p_hasFocus); boolean enabled = node.isEnabled();