MCPcopy Create free account
hub / github.com/apache/pig / Utils

Class Utils

src/org/apache/pig/impl/util/Utils.java:83–709  ·  view source on GitHub ↗

Class with utility static methods

Source from the content-addressed store, hash-verified

81 * Class with utility static methods
82 */
83public class Utils {
84 private static final Log log = LogFactory.getLog(Utils.class);
85 private static final Pattern JAVA_MAXHEAPSIZE_PATTERN = Pattern.compile("-Xmx(([0-9]+)[mMgG])");
86
87
88 /**
89 * This method checks whether JVM vendor is IBM
90 * @return true if IBM JVM is being used
91 * false otherwise
92 */
93 public static boolean isVendorIBM() {
94 return System.getProperty("java.vendor").contains("IBM");
95 }
96
97 public static boolean is64bitJVM() {
98 String arch = System.getProperties().getProperty("sun.arch.data.model",
99 System.getProperty("com.ibm.vm.bitmode"));
100 return arch != null && arch.equals("64");
101 }
102
103 /**
104 * This method is a helper for classes to implement {@link java.lang.Object#equals(java.lang.Object)}
105 * checks if two objects are equals - two levels of checks are
106 * made - first if both are null or not null. If either is null,
107 * check is made whether both are null.
108 * If both are non null, equality also is checked if so indicated
109 * @param obj1 first object to be compared
110 * @param obj2 second object to be compared
111 * @param checkEquality flag to indicate whether object equality should
112 * be checked if obj1 and obj2 are non-null
113 * @return true if the two objects are equal
114 * false otherwise
115 */
116 public static boolean checkNullEquals(Object obj1, Object obj2, boolean checkEquality) {
117 if(obj1 == null || obj2 == null) {
118 return obj1 == obj2;
119 }
120 if(checkEquality) {
121 if(!obj1.equals(obj2)) {
122 return false;
123 }
124 }
125 return true;
126 }
127
128
129 /**
130 * This method is a helper for classes to implement {@link java.lang.Object#equals(java.lang.Object)}
131 * The method checks whether the two arguments are both null or both not null and
132 * whether they are of the same class
133 * @param obj1 first object to compare
134 * @param obj2 second object to compare
135 * @return true if both objects are null or both are not null
136 * and if both are of the same class if not null
137 * false otherwise
138 */
139 public static boolean checkNullAndClass(Object obj1, Object obj2) {
140 if(checkNullEquals(obj1, obj2, false)) {

Callers

nothing calls this directly

Calls 1

compileMethod · 0.45

Tested by

no test coverage detected