List of usage examples for java.math BigInteger intValue
public int intValue()
From source file:org.jw.basex.js.rhino.Js.java
public Value put(Value jsObject, Value path, Value valueIn) throws QueryException { Context cx = Context.enter(); try {/*www. j ava 2 s .com*/ if (jsObject instanceof Map) { Map map = (Map) jsObject; jsObject = map.get(selfProperty(), null); } if (jsObject instanceof JsObject) { JsObject obj = (JsObject) jsObject; Scriptable item = obj.getScope(); Object value = Js.jsValue(valueIn, queryContext); if (path instanceof Str) { item.put(((Str) path).toJava(), item, value); } else if (path instanceof Int) { BigInteger index = (BigInteger) ((Int) path).toJava(); item.put(index.intValue(), item, value); } return Js.xqValue(item, cx, scope, null, queryContext); } } catch (Exception e) { Util.notExpected("Failed to put key " + path, e); } finally { Context.exit(); } throw new QueryException("Error: Putting value failed. " + invalidCastMessage); }
From source file:org.asqatasun.entity.dao.audit.ContentDAOImpl.java
@Override public List<Long> getRelatedContentFromWebResource(Long webResourceId, int start, int chunkSize) { if (webResourceId != null) { Query query = entityManager.createNativeQuery(SELECT_RELATED_CONTENT_QUERY); query.setParameter(ID_WEB_RESOURCE_KEY, webResourceId); query.setParameter("start", start); query.setParameter("chunkSize", chunkSize); List<Long> idList = new ArrayList<>(); for (BigInteger value : (List<BigInteger>) query.getResultList()) { idList.add(Long.valueOf(value.intValue())); }// w w w. j a v a 2 s .c o m flushAndCloseEntityManager(); return idList; } return null; }
From source file:org.jw.basex.js.rhino.Js.java
public Value remove(Value jsObject, Value path) throws QueryException { Context cx = Context.enter(); try {//from w w w.j a v a 2s . com if (jsObject instanceof Map) { Map map = (Map) jsObject; jsObject = map.get(selfProperty(), null); } if (jsObject instanceof JsObject) { JsObject obj = (JsObject) jsObject; Scriptable item = obj.getScope(); if (path instanceof Str) { item.delete(((Str) path).toJava()); } else if (path instanceof Int) { BigInteger index = (BigInteger) ((Int) path).toJava(); item.delete(index.intValue()); } return Js.xqValue(item, cx, scope, null, queryContext); } } catch (Exception e) { Util.notExpected("Failed to delete key " + path, e); } finally { Context.exit(); } throw new QueryException("Error: Removing value failed. " + invalidCastMessage); }
From source file:org.esupportail.portlet.filemanager.services.opencmis.CmisAccessImpl.java
@Override public DownloadFile getFile(String dir, SharedUserPortletParameters userParameters) { CmisObject cmisObject = getCmisObject(dir, userParameters); Document document = (Document) cmisObject; String filename = document.getName(); InputStream inputStream = document.getContentStream().getStream(); BigInteger size = (BigInteger) document.getProperty("cmis:contentStreamLength").getValues().get(0); String contentType = document.getContentStreamMimeType(); return new DownloadFile(contentType, size.intValue(), filename, inputStream); }
From source file:org.opens.tanaguru.entity.dao.audit.ContentDAOImpl.java
@Override public List<Long> getRelatedContentFromWebResource(Long webResourceId, int start, int chunkSize) { if (webResourceId != null) { Query query = entityManager.createNativeQuery(SELECT_RELATED_CONTENT_QUERY); query.setParameter(ID_WEB_RESOURCE_KEY, webResourceId); query.setParameter("start", start); query.setParameter("chunkSize", chunkSize); List<Long> idList = new ArrayList<Long>(); for (BigInteger value : (List<BigInteger>) query.getResultList()) { idList.add(Long.valueOf(value.intValue())); }/*w w w .ja va2 s. co m*/ flushAndCloseEntityManager(); return idList; } return null; }
From source file:org.openremote.controller.protocol.http.HttpGetCommand.java
private int resolveResultAsInteger(String rawResult) throws ConversionException { try {// w w w .jav a 2s . co m BigInteger min = new BigInteger(Integer.toString(Integer.MIN_VALUE)); BigInteger max = new BigInteger(Integer.toString(Integer.MAX_VALUE)); BigInteger result = new BigInteger(rawResult); if (result.compareTo(min) < 0) { return Integer.MIN_VALUE; } else if (result.compareTo(max) > 0) { return Integer.MAX_VALUE; } else { return result.intValue(); } } catch (NumberFormatException e) { throw new ConversionException("Cannot parse device return value to Java integer: " + e.getMessage(), e); } }
From source file:org.asqatasun.entity.dao.audit.ContentDAOImpl.java
/** * * @param webResourceId/* w ww.j a va 2 s.co m*/ * @param httpStatusCode * @param start * @param chunkSize * @return */ @Override public List<Long> getSSPFromWebResource(Long webResourceId, int httpStatusCode, int start, int chunkSize) { if (webResourceId != null) { StringBuilder strb = new StringBuilder(); strb.append(SELECT_SSP_QUERY); if (httpStatusCode != -1) { strb.append(HTTP_STATUS_EQUAL_OPTION); } else { strb.append(HTTP_STATUS_NOT_EQUAL_OPTION); } strb.append(LIMIT_OPTION); Query query = entityManager.createNativeQuery(strb.toString()); query.setParameter(ID_WEB_RESOURCE_KEY, webResourceId); query.setParameter(HTTP_STATUS_CODE_KEY, httpStatusCode); query.setParameter("start", start); query.setParameter("chunkSize", chunkSize); List<Long> idList = new ArrayList<>(); for (BigInteger value : (List<BigInteger>) query.getResultList()) { idList.add(Long.valueOf(value.intValue())); } flushAndCloseEntityManager(); return idList; } return null; }
From source file:org.jw.basex.js.rhino.Js.java
public Value get(Value jsObject, Value path, Bln recursive) throws QueryException { Context cx = Context.enter(); Scriptable parent = null;// w ww . j av a 2s . c om try { Object out = jsObject; if (jsObject instanceof Map) { Map map = (Map) jsObject; jsObject = map.get(selfProperty(), null); } if (jsObject instanceof JsObject) { JsObject obj = (JsObject) jsObject; if (path instanceof Str) { out = obj.getFromPath(((Str) path).toJava(), obj.getScope(), recursive.toJava()); parent = obj.getScope(); } else if (path instanceof Int) { BigInteger index = (BigInteger) ((Int) path).toJava(); out = obj.getScope().get(index.intValue(), obj.getScope()); } return Js.xqValue(out, cx, scope, parent, queryContext); } } catch (Exception e) { Util.notExpected("Failed to get key " + path, e); } finally { Context.exit(); } throw new QueryException("Error: " + invalidCastMessage); }
From source file:org.opens.tanaguru.entity.dao.audit.ContentDAOImpl.java
/** * * @param webResourceId/*from w w w . j a v a 2s.c o m*/ * @param start * @param chunkSize * @return */ @Override public List<Long> getSSPFromWebResource(Long webResourceId, int httpStatusCode, int start, int chunkSize) { if (webResourceId != null) { StringBuilder strb = new StringBuilder(); strb.append(SELECT_SSP_QUERY); if (httpStatusCode != -1) { strb.append(HTTP_STATUS_EQUAL_OPTION); } else { strb.append(HTTP_STATUS_NOT_EQUAL_OPTION); } strb.append(LIMIT_OPTION); Query query = entityManager.createNativeQuery(strb.toString()); query.setParameter(ID_WEB_RESOURCE_KEY, webResourceId); query.setParameter(HTTP_STATUS_CODE_KEY, httpStatusCode); query.setParameter("start", start); query.setParameter("chunkSize", chunkSize); List<Long> idList = new ArrayList<Long>(); for (BigInteger value : (List<BigInteger>) query.getResultList()) { idList.add(Long.valueOf(value.intValue())); } flushAndCloseEntityManager(); return idList; } return null; }
From source file:org.eclipse.om2m.core.router.Router.java
/** * In the case of a CREATE operation, the controller is determined by the * resource type argument from the generic request primitive. * @param resourceType //from ww w . j a v a 2s .c o m * @return the matching controller */ protected Controller getResourceControllerFromRT(BigInteger resourceType) { // test in case resourceType is null if (resourceType == null) { throw new BadRequestException("Resource type is missing for creation request"); } // switch case switch (resourceType.intValue()) { case ResourceType.CSE_BASE: return new CSEBaseController(); case ResourceType.ACCESS_CONTROL_POLICY: return new AccessControlPolicyController(); case ResourceType.AE: return new AEController(); case ResourceType.CONTAINER: return new ContainerController(); case ResourceType.CONTENT_INSTANCE: return new ContentInstanceController(); case ResourceType.REMOTE_CSE: return new RemoteCSEController(); case ResourceType.GROUP: return new GroupController(); case ResourceType.NODE: return new NodeController(); case ResourceType.SUBSCRIPTION: return new SubscriptionController(); case ResourceType.POLLING_CHANNEL: return new PollingChannelController(); default: throw new NotImplementedException("ResourceType: " + resourceType + " is not implemented"); } }