List of usage examples for java.lang Object getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:annis.test.TestHelper.java
private static String springFile(Object instance, String contextFile) { return springFile(instance.getClass(), contextFile); }
From source file:gaffer.serialisation.implementation.raw.CompactRawLongSerialiserTest.java
private static void test(final long value) throws SerialisationException { final byte[] b = SERIALISER.serialise(value); final Object o = SERIALISER.deserialise(b); assertEquals(Long.class, o.getClass()); assertEquals(value, o);//from www .j ava 2s .c o m final ByteArrayOutputStream baos = new ByteArrayOutputStream(); CompactRawSerialisationUtils.write(value, new DataOutputStream(baos)); final long result = CompactRawSerialisationUtils .read(new DataInputStream(new ByteArrayInputStream(baos.toByteArray()))); assertEquals(result, value); }
From source file:jahspotify.impl.NativeLogger.java
public static void d(final Object o) { if (o != null) System.out.println("d: " + o.getClass()); else/* www . ja va 2 s .c o m*/ System.out.println("d: null"); }
From source file:Main.java
public static void marshall(Object object, Node root, Marshaller.Listener listener) throws JAXBException { Marshaller marshaller = createMarshaller(object.getClass(), listener); marshaller.marshal(object, root);// ww w. j a va 2s . c om }
From source file:Main.java
public final static void save(Object object, String path) { try {/*from ww w.ja va2 s. c om*/ File file = new File(path); JAXBContext jaxbContext = JAXBContext.newInstance(object.getClass()); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); jaxbMarshaller.marshal(object, file); } catch (JAXBException e) { e.printStackTrace(); } }
From source file:ar.com.zauber.commons.spring.web.CommandURLParameterGenerator.java
/** * <p>//w w w .ja v a 2 s . c om * Methods usefull to generate the URL parameters for a command of a * Spring's <code>AbstractCommandController</code>. * </p> * <p> * It looks for getters (of any type) that have a matching setter with * string as argument, for example, a class with the methods: * * <blockquote><pre> * void setAction(String) * Action getAction() * void setSecret(String) * String getSecret() * </pre></blockquote> * </p> * <p> * And a set of objects of classes String and Action will return: * <blockquote><pre>?action=CANCEL&secret=supersecret</pre></blockquote> * </p> * * @param cmdClass * command class * @param values * a set set of the commands's objects * @return the parameter string */ public static String getURLParameter(final Class<?> cmdClass, final Set<?> values) { final Map<Class<?>, Object> map = new HashMap<Class<?>, Object>(); for (final Object object : values) { map.put(object.getClass(), object); } return getURLParameter(cmdClass, map); }
From source file:com.prey.ReflectionsUtils.java
public static void setProperty(String nameProperty, Object target, Object value) throws Exception { Class[] parameterTypes = { value.getClass() }; Method method = target.getClass().getMethod(nameProperty, parameterTypes); if (method != null) { Object[] paraneters = { value }; method.invoke(target, paraneters); }/* ww w .ja v a 2s . co m*/ }
From source file:com.smartitengineering.util.bean.BeanFactoryRegistrar.java
public static void aggregate(Object aggregator) { if (aggregator == null || aggregator.getClass().equals(Object.class)) { return;// w ww.j av a 2 s. c o m } Class<? extends Object> aggregatorClass = aggregator.getClass(); if (aggregate(aggregatorClass, aggregator)) { return; } }
From source file:info.magnolia.cms.util.FreeMarkerUtil.java
/** * Uses the class of the object to create the templates name and passes the object under the name 'this' * @param thisObj//ww w . j a va2s .c o m * @return the resuling string */ public static String process(Object thisObj) { return process(thisObj.getClass(), thisObj); }
From source file:Main.java
public static Object cut(Object obj, int size) { int j;/*w w w . ja va 2 s. com*/ if ((j = Array.getLength(obj)) == 1) { return Array.newInstance(obj.getClass().getComponentType(), 0); } int k; if ((k = j - size - 1) > 0) { System.arraycopy(obj, size + 1, obj, size, k); } j--; Object obj1 = Array.newInstance(obj.getClass().getComponentType(), j); System.arraycopy(obj, 0, obj1, 0, j); return obj1; }