MOA 12.03
Real Time Analytics for Data Streams
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * This program is distributed in the hope that it will be useful, 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00010 * GNU General Public License for more details. 00011 * 00012 * You should have received a copy of the GNU General Public License 00013 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00014 * 00015 */ 00016 00017 /* 00018 * SizeOf.java 00019 * Copyright (C) 2009 University of Waikato, Hamilton, New Zealand 00020 */ 00021 package moa.core; 00022 00023 import sizeof.agent.SizeOfAgent; 00024 00031 public class SizeOf { 00032 00034 protected static Boolean m_Present; 00035 00041 protected static synchronized boolean isPresent() { 00042 if (m_Present == null) { 00043 try { 00044 SizeOfAgent.fullSizeOf(new Integer(1)); 00045 m_Present = true; 00046 } catch (Throwable t) { 00047 m_Present = false; 00048 } 00049 } 00050 00051 return m_Present; 00052 } 00053 00060 public static long sizeOf(Object o) { 00061 if (isPresent()) { 00062 return SizeOfAgent.sizeOf(o); 00063 } else { 00064 return -1; 00065 } 00066 } 00067 00074 public static long fullSizeOf(Object o) { 00075 if (isPresent()) { 00076 return SizeOfAgent.fullSizeOf(o); 00077 } else { 00078 return -1; 00079 } 00080 } 00081 }