List of usage examples for java.lang Integer TYPE
Class TYPE
To view the source code for java.lang Integer TYPE.
Click Source Link
From source file:com.blackberry.bdp.test.utils.LocalZkServer.java
public LocalZkServer() throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IOException { String dataDirectory = System.getProperty("java.io.tmpdir"); dir = new File(dataDirectory, "zookeeper").getAbsoluteFile(); while (dir.exists()) { LOG.info("deleting {}", dir); FileUtils.deleteDirectory(dir);//from www .j av a2 s.c om } server = new ZooKeeperServer(dir, dir, tickTime); // The class that we need changed name between CDH3 and CDH4, so let's check // for the right version here. try { factoryClass = Class.forName("org.apache.zookeeper.server.NIOServerCnxnFactory"); standaloneServerFactory = factoryClass.newInstance(); Method configure = factoryClass.getMethod("configure", InetSocketAddress.class, Integer.TYPE); configure.invoke(standaloneServerFactory, new InetSocketAddress(clientPort), numConnections); Method startup = factoryClass.getMethod("startup", ZooKeeperServer.class); startup.invoke(standaloneServerFactory, server); } catch (ClassNotFoundException e) { LOG.info("Did not find NIOServerCnxnFactory"); try { factoryClass = Class.forName("org.apache.zookeeper.server.NIOServerCnxn$Factory"); Constructor<?> constructor = factoryClass.getConstructor(InetSocketAddress.class, Integer.TYPE); standaloneServerFactory = constructor.newInstance(new InetSocketAddress(clientPort), numConnections); Method startup = factoryClass.getMethod("startup", ZooKeeperServer.class); startup.invoke(standaloneServerFactory, server); } catch (ClassNotFoundException e1) { LOG.info("Did not find NIOServerCnxn.Factory"); throw new ClassNotFoundException("Can't find NIOServerCnxnFactory or NIOServerCnxn.Factory"); } } }
From source file:org.gachette.spi.callprocessor.DefaultCallProcessorTest.java
@Before public void setup() throws NoSuchMethodException { context = new DefaultCallContext() { };//from w w w . j a va2s . c o m callProcessor = new DefaultCallProcessor(graphProvider, proxyFactory, context); primitiveReadMethod = TestClass.class.getMethod("getPrimitive", null); primitiveWriteMethod = TestClass.class.getMethod("setPrimitive", Integer.TYPE); objectReadMethod = TestClass.class.getMethod("getObject", null); objectWriteMethod = TestClass.class.getMethod("setObject", Object.class); voidMethod = TestClass.class.getMethod("modify", Integer.TYPE); nonVoidMethod = TestClass.class.getMethod("state", null); hashCodeMethod = TestClass.class.getMethod("hashCode", null); equalsMethod = TestClass.class.getMethod("equals", Object.class); getOriginalObjectMethod = TestClass.class.getMethod("getOriginalObject", null); when(graphProvider.value(anyObject(), any(Method.class), any(Object[].class), any(CallProcessor.class))) .thenReturn(value); when(value.getValue()).thenReturn(oldValue); when(value.eval()).thenReturn(newValue); testObject = new TestClass(); }
From source file:com.blackberry.bdp.common.versioned.LocalZkServer.java
public LocalZkServer() throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IOException { String dataDirectory = System.getProperty("java.io.tmpdir"); dir = new File(dataDirectory, "zookeeper").getAbsoluteFile(); while (dir.exists()) { LOG.info("deleting {}", dir); FileUtils.deleteDirectory(dir);//from w w w . ja v a 2 s . c o m } server = new ZooKeeperServer(dir, dir, tickTime); // The class that we need changed name between CDH3 and CDH4, so let's // check // for the right version here. try { factoryClass = Class.forName("org.apache.zookeeper.server.NIOServerCnxnFactory"); standaloneServerFactory = factoryClass.newInstance(); Method configure = factoryClass.getMethod("configure", InetSocketAddress.class, Integer.TYPE); configure.invoke(standaloneServerFactory, new InetSocketAddress(clientPort), numConnections); Method startup = factoryClass.getMethod("startup", ZooKeeperServer.class); startup.invoke(standaloneServerFactory, server); } catch (ClassNotFoundException e) { LOG.info("Did not find NIOServerCnxnFactory"); try { factoryClass = Class.forName("org.apache.zookeeper.server.NIOServerCnxn$Factory"); Constructor<?> constructor = factoryClass.getConstructor(InetSocketAddress.class, Integer.TYPE); standaloneServerFactory = constructor.newInstance(new InetSocketAddress(clientPort), numConnections); Method startup = factoryClass.getMethod("startup", ZooKeeperServer.class); startup.invoke(standaloneServerFactory, server); } catch (ClassNotFoundException e1) { LOG.info("Did not find NIOServerCnxn.Factory"); throw new ClassNotFoundException("Can't find NIOServerCnxnFactory or NIOServerCnxn.Factory"); } } }
From source file:org.batoo.common.reflect.ReflectHelper.java
/** * Converts the number into number Type/* w w w. j a v a 2s . c om*/ * * @param value * the number value * @param numberType * the number type * @return the converted number value * * @since 2.0.1 */ public static Number convertNumber(Number value, Class<?> numberType) { if (value == null) { return null; } if (numberType.isAssignableFrom(value.getClass())) { return value; } if ((numberType == Integer.class) || (numberType == Integer.TYPE)) { return value.intValue(); } if ((numberType == Long.class) || (numberType == Long.TYPE)) { return value.longValue(); } if ((numberType == Short.class) || (numberType == Short.TYPE)) { return value.shortValue(); } if ((numberType == Byte.class) || (numberType == Byte.TYPE)) { return value.byteValue(); } if ((numberType == Float.class) || (numberType == Float.TYPE)) { return value.floatValue(); } if ((numberType == Double.class) || (numberType == Double.TYPE)) { return value.doubleValue(); } if (numberType == BigDecimal.class) { return BigDecimal.valueOf(value.doubleValue()); } if (numberType == BigInteger.class) { return BigInteger.valueOf(value.longValue()); } throw new IllegalArgumentException(numberType + " not supported"); }
From source file:org.esa.s2tbx.dataio.jp2.BoxType.java
public Box createBox(long offset, long length, int dataOffset) { try {/*from w w w .j a v a 2 s. co m*/ Constructor<? extends Box> boxConstructor = type.getConstructor(BoxType.class, Long.TYPE, Long.TYPE, Integer.TYPE); return boxConstructor.newInstance(this, offset, length, dataOffset); } catch (Exception e) { throw new IllegalStateException(e); } }
From source file:org.fhcrc.cpl.viewer.util.ConvertHelper.java
protected void register() { super.register(); ConvertUtils.register(new MyBooleanConverter(), Boolean.TYPE); ConvertUtils.register(new NullSafeConverter(new MyBooleanConverter()), Boolean.class); ConvertUtils.register(new NullSafeConverter(new ByteArrayConverter()), byte[].class); ConvertUtils.register(new PercentWrapper(new DoubleConverter()), Double.TYPE); ConvertUtils.register(new NullSafeConverter(new PercentWrapper(new DoubleConverter())), Double.class); ConvertUtils.register(new PercentWrapper(new FloatConverter()), Float.TYPE); ConvertUtils.register(new NullSafeConverter(new PercentWrapper(new FloatConverter())), Float.class); ConvertUtils.register(new ChargeWrapper(new IntegerConverter()), Integer.TYPE); ConvertUtils.register(new NullSafeConverter(new ChargeWrapper(new IntegerConverter())), Integer.class); ConvertUtils.register(new NullSafeConverter(new DateFriendlyStringConverter()), String.class); ConvertUtils.register(new LenientTimestampConverter(), java.sql.Timestamp.class); ConvertUtils.register(new LenientDateConverter(), java.util.Date.class); }
From source file:org.apereo.portal.fragment.subscribe.dao.jpa.JpaUserFragmentSubscriptionDaoImpl.java
@Override public void afterPropertiesSet() throws Exception { this.userIdParameter = this.createParameterExpression(Integer.TYPE, "userId"); this.fragmentOwnerParameter = this.createParameterExpression(String.class, "fragmentOwner"); this.findUserFragmentInfoByPersonQuery = this .createCriteriaQuery(new Function<CriteriaBuilder, CriteriaQuery<UserFragmentSubscriptionImpl>>() { @Override/*from w ww . j a v a 2s . c o m*/ public CriteriaQuery<UserFragmentSubscriptionImpl> apply(CriteriaBuilder cb) { final CriteriaQuery<UserFragmentSubscriptionImpl> criteriaQuery = cb .createQuery(UserFragmentSubscriptionImpl.class); final Root<UserFragmentSubscriptionImpl> root = criteriaQuery .from(UserFragmentSubscriptionImpl.class); criteriaQuery.select(root); criteriaQuery .where(cb.equal(root.get(UserFragmentSubscriptionImpl_.userId), userIdParameter)); return criteriaQuery; } }); this.findUserFragmentInfoByPersonAndOwnerQuery = this .createCriteriaQuery(new Function<CriteriaBuilder, CriteriaQuery<UserFragmentSubscriptionImpl>>() { @Override public CriteriaQuery<UserFragmentSubscriptionImpl> apply(CriteriaBuilder cb) { final CriteriaQuery<UserFragmentSubscriptionImpl> criteriaQuery = cb .createQuery(UserFragmentSubscriptionImpl.class); final Root<UserFragmentSubscriptionImpl> root = criteriaQuery .from(UserFragmentSubscriptionImpl.class); criteriaQuery.select(root); criteriaQuery.where( cb.and(cb.equal(root.get(UserFragmentSubscriptionImpl_.userId), userIdParameter), cb.equal(root.get(UserFragmentSubscriptionImpl_.fragmentOwner), fragmentOwnerParameter))); return criteriaQuery; } }); this.findUsersWithActiveSubscriptionsQuery = this .createCriteriaQuery(new Function<CriteriaBuilder, CriteriaQuery<String>>() { @Override public CriteriaQuery<String> apply(CriteriaBuilder cb) { final CriteriaQuery<String> criteriaQuery = cb.createQuery(String.class); final Root<UserFragmentSubscriptionImpl> root = criteriaQuery .from(UserFragmentSubscriptionImpl.class); criteriaQuery.select(root.get(UserFragmentSubscriptionImpl_.createdBy)); criteriaQuery.where(cb.equal(root.get(UserFragmentSubscriptionImpl_.active), true)); return criteriaQuery; } }); }
From source file:com.ms.commons.summer.web.util.json.JsonNumberMorpher.java
/** * Creates a new morpher for the target type with a default value.<br> * The defaultValue should be of the same class as the target type. * /*from w ww . j a va 2s. c o m*/ * @param type must be a primitive or wrapper type. BigDecimal and BigInteger are also supported. * @param defaultValue return value if the value to be morphed is null */ public JsonNumberMorpher(Class<?> type, Number defaultValue) { super(true); if (type == null) { throw new MorphException("Must specify a type"); } if (type != Byte.TYPE && type != Short.TYPE && type != Integer.TYPE && type != Long.TYPE && type != Float.TYPE && type != Double.TYPE && !Byte.class.isAssignableFrom(type) && !Short.class.isAssignableFrom(type) && !Integer.class.isAssignableFrom(type) && !Long.class.isAssignableFrom(type) && !Float.class.isAssignableFrom(type) && !Double.class.isAssignableFrom(type) && !BigInteger.class.isAssignableFrom(type) && !BigDecimal.class.isAssignableFrom(type)) { throw new MorphException("Must specify a Number subclass"); } this.type = type; }
From source file:at.ac.tuwien.infosys.jcloudscale.test.unit.TestReflectionUtil.java
@Test public void testPrimitiveConstructor() throws ReflectiveOperationException { Constructor<Integer> constructor = findConstructor(Integer.class, Integer.TYPE); assertEquals(Integer.class.getDeclaredConstructor(int.class), constructor); }
From source file:com.anaplan.client.transport.JCIFSEngine.java
/** {@inheritDoc} */ @Override// w w w . jav a 2 s. c om public String generateType1Msg(String domain, String workstation) throws NTLMEngineException { try { Object type1Message = TYPE_1_MESSAGE.getConstructor(Integer.TYPE, String.class, String.class) .newInstance(TYPE_1_FLAGS, domain, workstation); byte[] byteArray = (byte[]) TYPE_1_MESSAGE.getMethod("toByteArray").invoke(type1Message); return (String) BASE64.getMethod("encode", byteArray.getClass()).invoke(null, byteArray); } catch (Exception thrown) { throw new NTLMEngineException("Failed to generate NTLM type 1 message", thrown); } }