Java 8 CompositeData - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CompositeData class.

This code example shows how to use the following methods:containsValue
This code example shows how to use the following methods:containsKey
    } 
 
    private void assertHistoricalData( Object result ) { 
        assertNotNull(result); 
        CompositeData data = (CompositeData) result;
        assertTrue(data.containsKey("timeWindow"));
        assertTrue(data.containsKey("start"));
        assertTrue(data.containsKey("end"));
        assertTrue(data.containsKey("statisticalData"));
    } 
} 
7
CodeRank
This code example shows how to use the following methods:get
        TabularData td = InstanceToTableMapper.tableFrom(Collections.singletonList(instance));
        Collection<?> keys = (Collection<?>) td.keySet().iterator().next();
        Assert.assertEquals("MyInstance", keys.iterator().next());
         
        CompositeData cd = td.get(keys.toArray());
        Assert.assertEquals(1712, cd.get("Pid"));
        Assert.assertEquals("MyInstance", cd.get("Name"));
        Assert.assertEquals(false, cd.get("Is Root"));
        Assert.assertEquals(0, cd.get("SSH Port"));
        Assert.assertEquals(0, cd.get("RMI Registry Port"));
        Assert.assertEquals(0, cd.get("RMI Server Port"));
        Assert.assertEquals("Error", cd.get("State"));
        Assert.assertEquals("somewhere", cd.get("Location"));
        Assert.assertEquals("someopts", cd.get("JavaOpts"));
    } 
 
    public void testJMXInstance2() throws Exception {
        Instance instance = EasyMock.createMock(Instance.class);
        EasyMock.expect(instance.getPid()).andReturn(1712);
        EasyMock.expect(instance.getName()).andReturn("MyInstance");
6
CodeRank
This code example shows how to use the following methods:get
        assertEquals("test cancelled", status.getMessage()); 
    } 
 
    private static void checkConversion(Status status) { 
        CompositeData cd = status.toCompositeData();
        assertEquals(status.getCode().ordinal(), cd.get("code"));
        assertEquals(status.getId(), cd.get("id"));
        assertEquals(status.getMessage(), cd.get("message"));
 
        Status status2 = Status.fromCompositeData(cd);
        CompositeData cd2 = status2.toCompositeData();
        assertEquals(status, status2); 
        assertEquals(cd, cd2);
    } 
 
    @Test
    public void statusToCompositeDataConversion() { 
        checkConversion(Status.unavailable(42, "forty two")); 
        checkConversion(Status.none(43, "forty three")); 
        checkConversion(Status.initiated(44, "forty four")); 
6
CodeRank
This code example shows how to use the following methods:get
            CompositeData cd2 = result.get(new Object[]{objectName, "testMethod(java.lang.String)"});
            assertEquals(objectName, cd2.get("ObjectName"));
            assertEquals("testMethod(java.lang.String)", cd2.get("Method"));
            assertEquals(false, cd2.get("CanInvoke"));
            CompositeData cd3 = result.get(new Object[]{objectName, "otherMethod"});
            assertEquals(objectName, cd3.get("ObjectName"));
            assertEquals("otherMethod", cd3.get("Method"));
            assertEquals(true, cd3.get("CanInvoke"));
            CompositeData cd4 = result.get(new Object[]{objectName2, ""});
            assertEquals(objectName2, cd4.get("ObjectName"));
            assertEquals("", cd4.get("Method"));
            assertEquals(true, cd4.get("CanInvoke"));
            CompositeData cd5 = result.get(new Object[]{objectName3, ""});
            assertEquals(objectName3, cd5.get("ObjectName"));
            assertEquals("", cd5.get("Method"));
            assertEquals(false, cd5.get("CanInvoke"));
        } finally { 
            KarafMBeanServerBuilder.setGuard(prevGuard);
        } 
    } 
6
CodeRank
This code example shows how to use the following methods:containsKey, get
	 * @param cd composite data 
	 * @return Context class instance 
	 */ 
	public static Context from(CompositeData cd) {
		Context instance = new Context();
		if (cd.containsKey("context") && cd.containsKey("contextPath")) {
			Object context = cd.get("context");
			Object contextPath = cd.get("contextPath");
			if (context != null && contextPath != null) { 
				instance = new Context((ApplicationContext) context, (String) contextPath);
			} 
		} 
		return instance;
	}	 
	 
} 
6
CodeRank
This code example shows how to use the following methods:get
        CompositeData cd = (CompositeData) pValue;
 
        String pathPart = pPathParts.isEmpty() ? null : pPathParts.pop();
        if (pathPart != null) {
            try { 
                return pConverter.extractObject(cd.get(pathPart), pPathParts, jsonify);
            } catch (InvalidKeyException exp) {
                return pConverter.getValueFaultHandler().handleException(new AttributeNotFoundException("Invalid path '" + pathPart + "'"));
            } 
        } else { 
            return jsonify ? extractCompleteCdAsJson(pConverter, cd, pPathParts) : cd;
        } 
    } 
 
    private Object extractCompleteCdAsJson(ObjectToJsonConverter pConverter, CompositeData pData, Stack<String> pPath) throws AttributeNotFoundException {
        JSONObject ret = new JSONObject();
        for (String key : (Set<String>) pData.getCompositeType().keySet()) {
            Stack<String> path = (Stack<String>) pPath.clone();
            try { 
                ret.put(key, pConverter.extractObject(pData.get(key), path, true));
6
CodeRank
This code example shows how to use the following methods:get
        Long l = (Long) o;
 
        return l.longValue();
    } 
    public MyThreadInfo(String procConnect, CompositeData thread) {
        blockedTime = toLong(thread.get("blockedTime"),0);
        blockedCount = toLong(thread.get("blockedCount"), 0);
        name = (String) thread.get("threadName");
        id = toLong(thread.get("threadId"),0);
        stackTraceElems = (CompositeData []) thread.get("stackTrace");
        this.procConnect = procConnect;
    } 
 
    public MyThreadInfo(String procConnect, long threadId) {
 
        id = threadId;
        this.procConnect = procConnect;
    } 
 
    public MyThreadInfo(MyThreadInfo t1, MyThreadInfo t2) {
6
CodeRank
This code example shows how to use the following methods:get
        if (cd==null) { 
            return null; 
        } 
 
        return new ClassSummaryDetail(  
                (String)cd.get("Class Name"),
                (String)cd.get("Cache Type"),
                (String)cd.get("Current Size"),
                (String)cd.get("Parent Class Name"),
                (String)cd.get("Configured Size")
                ); 
    }     
    /** 
     * Convert an instance of this model specific type to  
     * a CompositeData. This ensure that clients that do not 
     * have access to the model specific class can still 
     * use the MBean. The MXBean framework can perform this 
     * conversion automatically.   
     *  
     * @param ct - This parameter is for JDK 1.6 compatibility reasons 
5
CodeRank
This code example shows how to use the following methods:get
        } 
        return 0l; 
    } 
 
    public long getPeriod() { 
        Long result = (Long) data.get("period");
        if (result != null) {
            return result.longValue();
        } 
        return 0l; 
    } 
 
    public int getRepeat() { 
        Integer result = (Integer) data.get("repeat");
        if (result != null) {
            return result.intValue();
        } 
        return 0; 
    } 
 
5
CodeRank
See Code Examples for Java 8 CompositeData Methods: