List of usage examples for java.lang Boolean valueOf
public static Boolean valueOf(String s)
From source file:lh.api.showcase.server.config.Configuration.java
@Override public synchronized HasProxySettings getHttpProxySettings() { if (isHttpProxyActive == null) { httpProxy = loadProxySetting("http", "proxy.http"); isHttpProxyActive = (httpProxy == null) ? (Boolean.FALSE) : (Boolean.valueOf(httpProxy.isActive())); }/*from w ww . j av a 2 s.co m*/ if (isHttpProxyActive) { return httpProxy; } else { return null; } }
From source file:org.nabucco.alfresco.enhScriptEnv.common.script.aop.ListLikeMapAdapterInterceptor.java
/** * {@inheritDoc}//from w w w .j a va 2 s . c o m */ @Override public Object invoke(final MethodInvocation invocation) throws Throwable { final Object result; final Method method = invocation.getMethod(); final Class<?> declaringClass = method.getDeclaringClass(); final Object this1 = invocation.getThis(); if ((List.class.equals(declaringClass) || Collection.class.equals(declaringClass)) && !(this1 instanceof List<?>)) { if (invocation instanceof ProxyMethodInvocation && ((ProxyMethodInvocation) invocation).getProxy() instanceof Map<?, ?>) { final Map<?, ?> map = (Map<?, ?>) ((ProxyMethodInvocation) invocation).getProxy(); final String methodName = method.getName(); boolean proceedInvocation = false; Object adaptedResult = null; final Object[] arguments = invocation.getArguments(); final Class<?>[] parameterTypes = method.getParameterTypes(); // String-switch not supported in Java < 8 switch (ListMethodName.methodLiteralOf(methodName)) { case SIZE: adaptedResult = Integer.valueOf(map.size()); break; case ISEMPTY: adaptedResult = Boolean.valueOf(map.isEmpty()); break; case CONTAINS: adaptedResult = Boolean.valueOf(map.containsValue(arguments[0])); break; case ITERATOR: adaptedResult = map.values().iterator(); break; case TOARRAY: adaptedResult = arguments.length == 1 ? map.values().toArray((Object[]) arguments[0]) : map.values().toArray(); break; case CONTAINSALL: adaptedResult = Boolean.valueOf(map.values().containsAll((Collection<?>) arguments[0])); break; case REMOVEALL: adaptedResult = Boolean.valueOf(map.values().removeAll((Collection<?>) arguments[0])); break; case INDEXOF: { int idx = 0; int foundIdx = -1; final Iterator<?> valueIterator = map.values().iterator(); while (valueIterator.hasNext()) { final Object el = valueIterator.next(); if (el == arguments[0] || (arguments[0] != null && arguments[0].equals(el))) { foundIdx = idx; break; } idx++; } adaptedResult = Integer.valueOf(foundIdx); } break; case LASTINDEXOF: { int idx = 0; int foundIdx = -1; final Iterator<?> valueIterator = map.values().iterator(); while (valueIterator.hasNext()) { final Object el = valueIterator.next(); if (el == arguments[0] || (arguments[0] != null && arguments[0].equals(el))) { foundIdx = idx; } idx++; } adaptedResult = Integer.valueOf(foundIdx); } break; case GET: { final int targetIdx = ((Integer) arguments[0]).intValue(); if (targetIdx < 0 || targetIdx >= map.size()) { throw new IndexOutOfBoundsException(); } int idx = 0; Object found = null; final Iterator<?> valueIterator = map.values().iterator(); while (valueIterator.hasNext()) { final Object el = valueIterator.next(); if (idx == targetIdx) { found = el; break; } idx++; } adaptedResult = found; } break; case REMOVE: { if (arguments[0] instanceof Integer && int.class.equals(parameterTypes[0])) { final int targetIdx = ((Integer) arguments[0]).intValue(); if (targetIdx < 0 || targetIdx >= map.size()) { throw new IndexOutOfBoundsException(); } int idx = 0; final Iterator<?> keyIterator = map.keySet().iterator(); Object keyToRemove = null; while (keyIterator.hasNext()) { final Object el = keyIterator.next(); if (idx == targetIdx) { keyToRemove = el; break; } idx++; } adaptedResult = keyToRemove != null ? map.remove(keyToRemove) : null; } else { adaptedResult = Boolean.valueOf(map.values().remove(arguments[0])); } } break; case RETAINALL: adaptedResult = Boolean.valueOf(map.values().retainAll((Collection<?>) arguments[0])); break; case CLEAR: map.clear(); break; case LISTITERATOR: // fallthrough case SUBLIST: // fallthrough case SET:// fallthrough case ADD:// fallthrough case ADDALL: // not supported throw new UnsupportedOperationException(); default: proceedInvocation = true; } if (proceedInvocation) { // may fail (if we have forgotten to map a specific operation or a new operation may have been introduced) result = invocation.proceed(); } else { result = adaptedResult; } } else { // may fail when other interceptors / target do not support List result = invocation.proceed(); } } else { // may fail when List was declaring class but type of "this" does not support this interceptor result = invocation.proceed(); } return result; }
From source file:org.jboss.as.testsuite.clustering.web.SimpleWebTestCase.java
@Test public void test() throws ClientProtocolException, IOException { DefaultHttpClient client = new DefaultHttpClient(); try {// www .jav a 2s . c om HttpResponse response = client.execute(new HttpGet("http://localhost:8080/distributable/simple")); Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertEquals(Integer.parseInt(response.getFirstHeader("value").getValue()), 1); Assert.assertFalse(Boolean.valueOf(response.getFirstHeader("serialized").getValue())); response.getEntity().getContent().close(); response = client.execute(new HttpGet("http://localhost:8080/distributable/simple")); Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertEquals(Integer.parseInt(response.getFirstHeader("value").getValue()), 2); // This won't be true unless we have somewhere to which to replicate Assert.assertFalse(Boolean.valueOf(response.getFirstHeader("serialized").getValue())); response.getEntity().getContent().close(); } finally { client.getConnectionManager().shutdown(); } }
From source file:com.pureinfo.srm.config.notice.model.NoticeItem.java
/** * @see com.pureinfo.force.xml.IXMLSupporter#fromXML(org.dom4j.Element) *//* w w w .ja v a 2s .c om*/ public void fromXML(Element _element) throws PureException { m_sName = _element.attributeValue(ATTRIBUTE_NAME); m_bChecked = Boolean.valueOf(_element.elementText(ELEMENT_CHECKED)).booleanValue(); m_nDay = Integer.parseInt(_element.elementText(ELEMENT_DAY)); m_sText = _element.elementText(ELEMENT_TEXT); }
From source file:blue.soundObject.jmask.Parameter.java
public static Parameter loadFromXML(Element data) throws Exception { Parameter parameter = new Parameter(); if (data.getAttributeValue("visible") != null) { boolean visible = Boolean.valueOf(data.getAttributeValue("visible")).booleanValue(); parameter.setVisible(visible);/* ww w. j a v a 2 s . c o m*/ } if (data.getAttributeValue("name") != null) { parameter.setName(data.getAttributeValue("name")); } Elements nodes = data.getElements(); while (nodes.hasMoreElements()) { Element node = nodes.next(); String nodeName = node.getName(); if (nodeName.equals("generator")) { parameter.generator = (Generator) ObjectUtilities.loadFromXML(node); } else if (nodeName.equals("mask")) { parameter.mask = Mask.loadFromXML(node); } else if (nodeName.equals("quantizer")) { parameter.quantizer = Quantizer.loadFromXML(node); } else if (nodeName.equals("accumulator")) { parameter.accumulator = Accumulator.loadFromXML(node); } } return parameter; }
From source file:com.googlecode.gmaps4jsf.jsfplugin.digester.Attribute.java
public boolean isIgnored() { return Boolean.valueOf(ignoreInComponent).booleanValue(); }
From source file:org.restdoc.api.util.RestDocObject.java
/** * @param fieldName//from ww w.j a v a 2 s.c o m * @return the value as Boolean */ @JsonIgnore public Boolean getAdditionalBoolean(final String fieldName) { final Object object = this.getAdditionalField(fieldName); if (object instanceof Boolean) { return (Boolean) object; } return Boolean.valueOf(object.toString()); }
From source file:jp.aegif.nemaki.cmis.factory.info.Capabilities.java
@PostConstruct public void init() { ////////////////////////////////////////////////////////////////// // Navigation Capabilities ////////////////////////////////////////////////////////////////// // capabiliyGetDescendants setSupportsGetDescendants(Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_GET_DESCENDENTS))); // capabilityGetFolderTree setSupportsGetFolderTree(Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_GET_FOLDER_TREE))); // capabilityOrderBy setCapabilityOrderBy(CapabilityOrderBy.fromValue(pm.readValue(PropertyKey.CAPABILITY_ORDER_BY))); ////////////////////////////////////////////////////////////////// // Object Capabilities ////////////////////////////////////////////////////////////////// // capabilityContentStreamUpdatability setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates .fromValue(pm.readValue(PropertyKey.CAPABILITY_CONTENT_STREAM_UPDATABILITY))); //capabilityChanges setCapabilityChanges(CapabilityChanges.fromValue(pm.readValue(PropertyKey.CAPABILITY_CHANGES))); //capabilityRenditions setCapabilityRendition(CapabilityRenditions.fromValue(pm.readValue(PropertyKey.CAPABILITY_RENDITIONS))); ////////////////////////////////////////////////////////////////// // Filing Capabilities ////////////////////////////////////////////////////////////////// //capabilityMultifiling setSupportsMultifiling(Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_MULTIFILING))); //capabilityUnfiling setSupportsUnfiling(Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_UNFILING))); //capabilityVersionSpecificFiling setSupportsVersionSpecificFiling(//from ww w . ja v a 2s. c o m Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_VERSION_SPECIFIC_FILING))); ////////////////////////////////////////////////////////////////// // Versioning Capabilities ////////////////////////////////////////////////////////////////// //capabilityPWCUpdatable setIsPwcUpdatable(Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_PWC_UPDATABLE))); //capabilityPWCSearchable setIsPwcSearchable(Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_PWC_SEARCHABLE))); // capabilityAllVersionsSearchable setAllVersionsSearchable(Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_ALL_VERSION_SEARCHABLE))); ////////////////////////////////////////////////////////////////// // Query Capabilities ////////////////////////////////////////////////////////////////// // capabilityQuery setCapabilityQuery(CapabilityQuery.fromValue(pm.readValue(PropertyKey.CAPABILITY_QUERY))); // capabilityJoin setCapabilityJoin(CapabilityJoin.fromValue(pm.readValue(PropertyKey.CAPABILITY_JOIN))); ////////////////////////////////////////////////////////////////// // Type Capabilities ////////////////////////////////////////////////////////////////// //capabilityCreatablPopertyTypes CreatablePropertyTypesImpl creatablePropertyTypes = new CreatablePropertyTypesImpl(); List<String> _propertyTypes = pm.readValues(PropertyKey.CAPABILITY_CREATABLE_PROPERTY_TYPES); Set<PropertyType> propertyTypes = new HashSet<PropertyType>(); if (CollectionUtils.isNotEmpty(_propertyTypes)) { for (String _pt : _propertyTypes) { propertyTypes.add(PropertyType.fromValue(_pt)); } } creatablePropertyTypes.setCanCreate(propertyTypes); setCreatablePropertyTypes(creatablePropertyTypes); //capabilityNewTypeSettableAttributes NewTypeSettableAttributesImpl newTypeSettableAttributes = new NewTypeSettableAttributesImpl(); newTypeSettableAttributes .setCanSetId(Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_NEW_TYPE_SETTABLE_ATTRIBUTES_ID))); newTypeSettableAttributes.setCanSetLocalName( Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCAL_NAME))); newTypeSettableAttributes.setCanSetLocalNamespace(Boolean .valueOf(pm.readValue(PropertyKey.CAPABILITY_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCAL_NAME_SPACE))); newTypeSettableAttributes.setCanSetQueryName( Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_NEW_TYPE_SETTABLE_ATTRIBUTES_QUERY_NAME))); newTypeSettableAttributes.setCanSetDisplayName( Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_NEW_TYPE_SETTABLE_ATTRIBUTES_DISPLAY_NAME))); newTypeSettableAttributes.setCanSetDescription( Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_NEW_TYPE_SETTABLE_ATTRIBUTES_DESCRIPTION))); newTypeSettableAttributes.setCanSetCreatable( Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_NEW_TYPE_SETTABLE_ATTRIBUTES_CREATABLE))); newTypeSettableAttributes.setCanSetFileable( Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_NEW_TYPE_SETTABLE_ATTRIBUTES_FILEABLE))); newTypeSettableAttributes.setCanSetQueryable( Boolean.valueOf(pm.readValue(PropertyKey.CAPABILITY_NEW_TYPE_SETTABLE_ATTRIBUTES_QUERYABLE))); newTypeSettableAttributes.setCanSetFulltextIndexed(Boolean .valueOf(pm.readValue(PropertyKey.CAPABILITY_NEW_TYPE_SETTABLE_ATTRIBUTES_FULLTEXT_INDEXED))); newTypeSettableAttributes.setCanSetIncludedInSupertypeQuery(Boolean.valueOf( pm.readValue(PropertyKey.CAPABILITY_NEW_TYPE_SETTABLE_ATTRIBUTES_INCLUDE_IN_SUPERTYPE_QUERY))); newTypeSettableAttributes.setCanSetControllablePolicy(Boolean .valueOf(pm.readValue(PropertyKey.CAPABILITY_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLLABLE_POLICY))); newTypeSettableAttributes.setCanSetControllableAcl(Boolean .valueOf(pm.readValue(PropertyKey.CAPABILITY_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLLABLE_ACL))); setNewTypeSettableAttributes(newTypeSettableAttributes); ////////////////////////////////////////////////////////////////// // ACL Capabilities ////////////////////////////////////////////////////////////////// // capabilityACL setCapabilityAcl(CapabilityAcl.fromValue(pm.readValue(PropertyKey.CAPABILITY_ACL))); }
From source file:de.tudarmstadt.lt.nlkg.EvaluateArgs.java
static void evaluate(String file) throws IllegalArgumentException, FileNotFoundException { DT dt = new DT() { {/*from w ww .j av a 2s.c o m*/ _mysql_host = "localhost"; _mysql_dbname = "nlkg_1"; } }; LineIterator iter = new LineIterator(new FileReader(file)); iter.nextLine(); // skip first line int lineno = 1; double tp = 0d, tn = 0d, fp = 0d, fn = 0d; while (iter.hasNext() && (lineno < 100 || true)) { lineno++; String line = iter.nextLine(); if (line.trim().isEmpty()) continue; String[] splits = line.split("\t"); // String context = splits[0].trim(); String arg_l = splits[0].trim(); String arg_r = splits[1].trim(); boolean entailing_trueclass = Boolean.valueOf(splits[2].trim()); // _CONTEXT.add(context); _ARG_L.add(arg_l); _ARG_R.add(arg_r); _ENTAILING.add(entailing_trueclass); boolean entailing_predicted = predictEntailing(dt, arg_l, arg_r); if (lineno % 100 == 0) Evaluate.log_progress(); if (entailing_predicted && entailing_trueclass) { Evaluate.log_true(String.format("%d %-10s %-30s %-30s %b %n", lineno, "tp", arg_l, arg_r, entailing_trueclass)); tp++; } if (!entailing_predicted && !entailing_trueclass) { Evaluate.log_true(String.format("%d %-10s %-30s %-30s %b %n", lineno, "tn", arg_l, arg_r, entailing_trueclass)); tn++; } if (entailing_predicted && !entailing_trueclass) { Evaluate.log_false(String.format("%d %-10s %-30s %-30s %b %n", lineno, "fp", arg_l, arg_r, entailing_trueclass)); fp++; } if (!entailing_predicted && entailing_trueclass) { Evaluate.log_false(String.format("%d %-10s %-30s %-30s %b %n", lineno, "fn", arg_l, arg_r, entailing_trueclass)); fn++; } } dt.disconnect(); System.out.format("%ntp: %d; fp: %d; fn: %d; tn: %d; %n", (int) tp, (int) fp, (int) fn, (int) tn); System.out.println("Precision = " + (tp / (tp + fp))); System.out.println("Recall = " + (tp / (tp + fn))); System.out.println("F1 = " + ((2 * tp) / ((2 * tp) + fn + fp))); }
From source file:com.googlesource.gerrit.plugins.rabbitmq.config.AMQProperties.java
public AMQProperties(PluginProperties properties) { this.message = properties.getSection(Message.class); this.headers = new HashMap<>(); for (Section section : properties.getSections()) { for (Field f : section.getClass().getFields()) { if (f.isAnnotationPresent(MessageHeader.class)) { MessageHeader mh = f.getAnnotation(MessageHeader.class); try { Object value = f.get(section); if (value == null) { continue; }// w ww . ja v a 2 s. c o m switch (f.getType().getSimpleName()) { case "String": headers.put(mh.value(), value.toString()); break; case "Integer": headers.put(mh.value(), Integer.valueOf(value.toString())); break; case "Long": headers.put(mh.value(), Long.valueOf(value.toString())); break; case "Boolean": headers.put(mh.value(), Boolean.valueOf(value.toString())); break; default: break; } } catch (IllegalAccessException | IllegalArgumentException ex) { LOGGER.warn("Cannot access field {}. Cause: {}", f.getName(), ex.getMessage()); } } } } }