List of usage examples for org.apache.commons.lang ArrayUtils add
public static short[] add(short[] array, short element)
Copies the given array and adds the given element at the end of the new array.
From source file:nl.intercommit.weaves.components.InPlaceSelectBox.java
StreamResponse onAction(Object[] ctx) throws UnsupportedEncodingException { String valueText = request.getParameter("value"); resources.triggerEvent(SAVE_EVENT, ArrayUtils.add(ctx, valueText), null); if (valueText == null || valueText.length() == 0) { valueText = emptyMessageKey;//from www .ja v a 2s .co m } else { valueText = content.get(Long.valueOf(valueText)); } return new TextStreamResponse("text/html", new String(valueText.getBytes("UTF8"))); }
From source file:org.acoustid.server.util.ParameterMap.java
public static ParameterMap parseRequest(HttpServletRequest request) throws IOException { String contentEncoding = request.getHeader("Content-Encoding"); if (contentEncoding != null) { contentEncoding = contentEncoding.toLowerCase(); }//from w w w. j a v a2 s . com String contentType = request.getContentType(); Map<String, String[]> map; if ("gzip".equals(contentEncoding) && "application/x-www-form-urlencoded".equals(contentType)) { InputStream inputStream = new GZIPInputStream(request.getInputStream()); InputStreamEntity entity = new InputStreamEntity(inputStream, -1); entity.setContentType(contentType); map = new HashMap<String, String[]>(); for (NameValuePair param : URLEncodedUtils.parse(entity)) { String name = param.getName(); String value = param.getValue(); String[] values = map.get(name); if (values == null) { values = new String[] { value }; } else { values = (String[]) ArrayUtils.add(values, value); } map.put(name, values); } } else { map = request.getParameterMap(); } return new ParameterMap(map); }
From source file:org.agiso.core.logging.slf4j.SLF4JLogger.java
@Override public void trace(Throwable t, String message, Object... args) { if (args == null || args.length == 0) { logger.trace(message, t);/* www.jav a 2 s .com*/ } else { logger.trace(message, ArrayUtils.add(args, t)); } }
From source file:org.agiso.core.logging.slf4j.SLF4JLogger.java
@Override public void debug(Throwable t, String message, Object... args) { if (args == null || args.length == 0) { logger.debug(message, t);//ww w . j a v a2 s .c om } else { logger.debug(message, ArrayUtils.add(args, t)); } }
From source file:org.agiso.core.logging.slf4j.SLF4JLogger.java
@Override public void info(Throwable t, String message, Object... args) { if (args == null || args.length == 0) { logger.info(message, t);// w w w . ja va 2 s.c om } else { logger.info(message, ArrayUtils.add(args, t)); } }
From source file:org.agiso.core.logging.slf4j.SLF4JLogger.java
@Override public void warn(Throwable t, String message, Object... args) { if (args == null || args.length == 0) { logger.warn(message, t);/* ww w . jav a 2 s.com*/ } else { logger.warn(message, ArrayUtils.add(args, t)); } }
From source file:org.agiso.core.logging.slf4j.SLF4JLogger.java
@Override public void error(Throwable t, String message, Object... args) { if (args == null || args.length == 0) { logger.error(message, t);/*from ww w.j a v a 2s .c om*/ } else { logger.error(message, ArrayUtils.add(args, t)); } }
From source file:org.alfresco.repo.workflow.activiti.ActivitiSpringTest.java
private String[] getConfigLocations() { String[] defaultLocations = ApplicationContextHelper.CONFIG_LOCATIONS; Object[] locations = ArrayUtils.add(defaultLocations, ACTIVITI_CONTEXT); return (String[]) locations; }
From source file:org.apache.cxf.jaxbplus.io.DataWriterImpl.java
public void write(Object obj, MessagePartInfo part, T output) { boolean honorJaxbAnnotation = honorJAXBAnnotations(part); if (part != null && !part.isElement() && part.getTypeClass() != null) { honorJaxbAnnotation = true;/*from w w w.j ava 2s.com*/ } if (obj != null || !(part.getXmlSchema() instanceof XmlSchemaElement)) { if (obj instanceof Exception && part != null && Boolean.TRUE .equals(part.getProperty(JAXBDataBinding.class.getName() + ".CUSTOM_EXCEPTION"))) { JAXBEncoderDecoder.marshallException(createMarshaller(obj, part), (Exception) obj, part, output); } else { Annotation[] anns = getJAXBAnnotation(part); XmlJavaTypeAdapter adapter = JefAdapters.get(part.getTypeClass()); if (adapter != null) { anns = (Annotation[]) ArrayUtils.add(anns, adapter); honorJaxbAnnotation = true; } if (!honorJaxbAnnotation || anns.length == 0) { JAXBEncoderDecoder.marshall(createMarshaller(obj, part), obj, part, output); } else if (honorJaxbAnnotation && anns.length > 0) { //RpcLit will use the JAXB Bridge to marshall part message when it is //annotated with @XmlList,@XmlAttachmentRef,@XmlJavaTypeAdapter //TODO:Cache the JAXBRIContext QName qname = new QName(null, part.getConcreteName().getLocalPart()); JAXBEncoderDecoder.marshalWithBridge(qname, part.getTypeClass(), anns, databinding.getContextClasses(), obj, output, getAttachmentMarshaller()); } } } else if (obj == null && needToRender(obj, part)) { JAXBEncoderDecoder.marshallNullElement(createMarshaller(obj, part), output, part); } }
From source file:org.apache.hadoop.hbase.client.TestFromClientSide.java
@Test public void testRawScanRespectsVersions() throws Exception { byte[] TABLE = Bytes.toBytes("testRawScan"); HTable table = TEST_UTIL.createTable(TABLE, new byte[][] { FAMILY }); byte[] row = Bytes.toBytes("row"); // put the same row 4 times, with different values Put p = new Put(row); p.add(FAMILY, QUALIFIER, 10, VALUE); table.put(p);// www. j ava 2 s . c o m table.flushCommits(); p = new Put(row); p.add(FAMILY, QUALIFIER, 11, ArrayUtils.add(VALUE, (byte) 2)); table.put(p); table.flushCommits(); p = new Put(row); p.add(FAMILY, QUALIFIER, 12, ArrayUtils.add(VALUE, (byte) 3)); table.put(p); table.flushCommits(); p = new Put(row); p.add(FAMILY, QUALIFIER, 13, ArrayUtils.add(VALUE, (byte) 4)); table.put(p); table.flushCommits(); int versions = 4; Scan s = new Scan(row); // get all the possible versions s.setMaxVersions(); s.setRaw(true); ResultScanner scanner = table.getScanner(s); int count = 0; for (Result r : scanner) { assertEquals("Found an unexpected number of results for the row!", versions, r.listCells().size()); count++; } assertEquals("Found more than a single row when raw scanning the table with a single row!", 1, count); scanner.close(); // then if we decrease the number of versions, but keep the scan raw, we should see exactly that // number of versions versions = 2; s.setMaxVersions(versions); scanner = table.getScanner(s); count = 0; for (Result r : scanner) { assertEquals("Found an unexpected number of results for the row!", versions, r.listCells().size()); count++; } assertEquals("Found more than a single row when raw scanning the table with a single row!", 1, count); scanner.close(); // finally, if we turn off raw scanning, but max out the number of versions, we should go back // to seeing just three versions = 3; s.setMaxVersions(versions); scanner = table.getScanner(s); count = 0; for (Result r : scanner) { assertEquals("Found an unexpected number of results for the row!", versions, r.listCells().size()); count++; } assertEquals("Found more than a single row when raw scanning the table with a single row!", 1, count); scanner.close(); table.close(); TEST_UTIL.deleteTable(TABLE); }