List of usage examples for java.lang NullPointerException NullPointerException
public NullPointerException(String s)
From source file:FileUtils.java
/** * /*from www.ja v a 2s . c om*/ * Merges the two paths to create a valid version of the second path. This * method should be used when you encounter a relative path in a document and * must resolve it based on the path of the current document. An example would * be: <br> * <br> * <b>original path</b> - files/customers/Orders.xml <br> * <br> * <b>relative path</b> - ../Accounts.xml <br> * <br> * <b>result</b> - files/customers/Accounts.xml <br> * <br> * The only time this method cannot be used is if the original path is for a * file that is in the root (has no directory as part of its path) and the * relative path starts with "..". * * @param originalPath * The path of the file that references another file. * * @param relativePath * The path of the other file, which is relative to the original. * * @return A proper path for the other file, one that can be used to open and * verify the file. * */ public static String createRelativePath(String originalPath, String relativePath) { if (originalPath == null) throw new NullPointerException("NullOriginalPath"); if (relativePath == null) throw new NullPointerException("NullRelativePath"); // // remove ./ if present // if (relativePath.startsWith("./")) relativePath = relativePath.substring(2); // // remove any .. reference by taking off the last section/ of // the original path // if (relativePath.startsWith("../")) { int slash = originalPath.lastIndexOf('/'); originalPath = originalPath.substring(0, slash); relativePath = relativePath.substring(3); } int slash = originalPath.lastIndexOf('/'); if (slash < 0) return relativePath; String dir = originalPath.substring(0, slash + 1); return dir + relativePath; }
From source file:com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField.java
public static SpanEventBitField buildFirst(SpanEventBo spanEventBo) { if (spanEventBo == null) { throw new NullPointerException("spanEventBo must not be null"); }/* w ww .j av a 2 s .co m*/ final SpanEventBitField bitFiled = new SpanEventBitField(); if (spanEventBo.getRpc() != null) { bitFiled.setRpc(true); } if (spanEventBo.getEndPoint() != null) { bitFiled.setEndPoint(true); } if (spanEventBo.getDestinationId() != null) { bitFiled.setDestinationId(true); } if (spanEventBo.getNextSpanId() != -1) { bitFiled.setNextSpanId(true); } if (spanEventBo.hasException()) { bitFiled.setHasException(true); } final List<AnnotationBo> annotationBoList = spanEventBo.getAnnotationBoList(); if (CollectionUtils.isNotEmpty(annotationBoList)) { bitFiled.setAnnotation(true); } if (spanEventBo.getNextAsyncId() != -1) { bitFiled.setNextAsyncId(true); } if (spanEventBo.getAsyncId() == -1 && spanEventBo.getAsyncSequence() == -1) { bitFiled.setAsyncId(false); } else { bitFiled.setAsyncId(true); } return bitFiled; }
From source file:core.cms.services2.PagesCmsNavigationServiceImpl.java
public void init() { StringBuilder sb = new StringBuilder(); common.utils.MiscUtils.checkNotNull(pagesService, "pagesService", sb); if (sb.length() > 0) { throw new NullPointerException(sb.toString()); }/*from w ww . ja v a2s . c om*/ }
From source file:descriptordump.dumpexecutor.AbstractExecutor.java
protected AbstractExecutor(TABLE_ID tid, TABLE_ID... tids) { List<TABLE_ID> t = new ArrayList<>(); if (tid != null) { t.add(tid);// www. java 2 s . c o m } else { throw new NullPointerException("ID??????"); } if (tids != null) { t.addAll(Arrays.asList(tids)); } Set<TABLE_ID> temp = Collections.synchronizedSet(new HashSet<>()); temp.addAll(t); this.tids = Collections.unmodifiableSet(temp); }
From source file:com.github.jinahya.codec.commons.BinaryDecoderProxy.java
/** * Creates a new proxy instance./*from w ww .j a va 2 s . c o m*/ * * @param <P> proxy type parameter. * @param <T> decoder type parameter * @param proxyType proxy type * @param decoderType decoder type * @param decoder decoder * * @return a new (proxy) instance. */ protected static <P extends AbstractDecoderProxy<T>, T> Object newInstance(final Class<P> proxyType, final Class<T> decoderType, final T decoder) { if (proxyType == null) { throw new NullPointerException("proxyType"); } if (!BinaryDecoderProxy.class.isAssignableFrom(proxyType)) { throw new IllegalArgumentException( "proxyType(" + proxyType + ") is not assignable to " + BinaryDecoderProxy.class); } return newInstance(DECODER.getClassLoader(), new Class<?>[] { DECODER }, proxyType, decoderType, decoder); }
From source file:is.illuminati.block.spyros.garmin.parser.digester.DateTimeConverter.java
@SuppressWarnings("rawtypes") @Override/*from w w w .j a v a 2 s. c o m*/ public Object convert(final Class type, final Object value) { if (type == null) throw new NullPointerException("type cannot be null"); if (value == null) throw new NullPointerException("value cannot be null"); if (type != DateTime.class) throw new IllegalArgumentException("wrong type class"); if (!String.class.isAssignableFrom(value.getClass())) throw new IllegalArgumentException("wrong value class"); return dateTimeFormatter.parseDateTime((String) value); }
From source file:org.atemsource.atem.impl.json.attribute.LongAttribute.java
@Override public Long getValue(Object entity) { ObjectNode node = (ObjectNode) entity; if (node.isNull()) { throw new NullPointerException("entity is null"); } else {/*from ww w . j ava 2 s .c om*/ JsonNode jsonNode = node.get(getCode()); if (jsonNode == null || jsonNode.isNull()) { return null; } else { if (!jsonNode.isNumber()) { throw new ConversionException(jsonNode.getValueAsText(), getTargetType()); } return jsonNode.getLongValue(); } } }
From source file:com.sap.prd.mobile.ios.mios.RemoveTrailingCharactersVersionTransformer.java
public String transform(String version) throws NumberFormatException { final String originalVersion = version; if (version == null) throw new NullPointerException("Version was null."); String[] parts = version.split("\\."); List<String> result = new ArrayList<String>(); int length = (limit == -1 ? parts.length : Math.min(parts.length, limit)); for (int i = 0; i < length; i++) { String part = removeTrailingNonNumbers(parts[i]); if (part.trim().isEmpty()) part = "0"; if (Long.parseLong(part) < 0) { throw new NumberFormatException("Invalid version found: '" + originalVersion + "'. Negativ version part found: " + parts[i] + "."); }/*from w w w . java 2 s . co m*/ result.add(part); if (!parts[i].matches("\\d+")) break; } while (result.size() < limit) result.add("0"); return StringUtils.join(result, '.'); }
From source file:eu.esdihumboldt.hale.io.haleconnect.HaleConnectUrnBuilder.java
private static String[] splitProjectUrn(URI urn) { if (urn == null) { throw new NullPointerException("URN must not be null"); } else if (!SCHEME_HALECONNECT.equals(urn.getScheme().toLowerCase())) { throw new IllegalArgumentException( MessageFormat.format("URN must have scheme \"{0}\"", SCHEME_HALECONNECT)); }//from www.ja va 2 s . com if (StringUtils.isEmpty(urn.getSchemeSpecificPart())) { throw new IllegalArgumentException(MessageFormat.format("Malformed URN: {0}", urn.toString())); } String[] parts = urn.getSchemeSpecificPart().split(":"); if (parts.length != 4) { throw new IllegalArgumentException(MessageFormat.format("Malformed URN: {0}", urn.toString())); } else if (!"project".equals(parts[0])) { throw new IllegalArgumentException(MessageFormat.format("No a project URN: {0}", urn.toString())); } return parts; }
From source file:com.mattermost.service.jacksonconverter.JacksonConverterFactory.java
private JacksonConverterFactory(ObjectMapper mapper) { if (mapper == null) throw new NullPointerException("mapper == null"); this.mapper = mapper; this.mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); this.mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); }