code
stringlengths
130
281k
code_dependency
stringlengths
182
306k
public class class_name { public static base_responses delete(nitro_service client, location resources[]) throws Exception { base_responses result = null; if (resources != null && resources.length > 0) { location deleteresources[] = new location[resources.length]; for (int i=0;i<resources.length;i++){ deleteresources[i] = new location(); deleteresources[i].ipfrom = resources[i].ipfrom; deleteresources[i].ipto = resources[i].ipto; } result = delete_bulk_request(client, deleteresources); } return result; } }
public class class_name { public static base_responses delete(nitro_service client, location resources[]) throws Exception { base_responses result = null; if (resources != null && resources.length > 0) { location deleteresources[] = new location[resources.length]; for (int i=0;i<resources.length;i++){ deleteresources[i] = new location(); // depends on control dependency: [for], data = [i] deleteresources[i].ipfrom = resources[i].ipfrom; // depends on control dependency: [for], data = [i] deleteresources[i].ipto = resources[i].ipto; // depends on control dependency: [for], data = [i] } result = delete_bulk_request(client, deleteresources); } return result; } }
public class class_name { @Override public void refresh(final boolean layoutUpdated) { final RecyclerView contentView = getContentView(); if (contentView == null) { return; } if (contentView.getScrollState() != RecyclerView.SCROLL_STATE_IDLE) { // contentView.stopScroll(); } updateRunnable = new Runnable() { @Override public void run() { if (!contentView.isComputingLayout()) { //to prevent notify update when recyclerView is in computingLayout process mGroupBasicAdapter.notifyUpdate(layoutUpdated); if (mSwipeItemTouchListener != null) { mSwipeItemTouchListener.updateCurrCard(); } } } }; contentView.post(updateRunnable); } }
public class class_name { @Override public void refresh(final boolean layoutUpdated) { final RecyclerView contentView = getContentView(); if (contentView == null) { return; // depends on control dependency: [if], data = [none] } if (contentView.getScrollState() != RecyclerView.SCROLL_STATE_IDLE) { // contentView.stopScroll(); } updateRunnable = new Runnable() { @Override public void run() { if (!contentView.isComputingLayout()) { //to prevent notify update when recyclerView is in computingLayout process mGroupBasicAdapter.notifyUpdate(layoutUpdated); // depends on control dependency: [if], data = [none] if (mSwipeItemTouchListener != null) { mSwipeItemTouchListener.updateCurrCard(); // depends on control dependency: [if], data = [none] } } } }; contentView.post(updateRunnable); } }
public class class_name { protected final void closeSession() { if (sessionTracker != null) { Session currentSession = sessionTracker.getOpenSession(); if (currentSession != null) { currentSession.close(); } } } }
public class class_name { protected final void closeSession() { if (sessionTracker != null) { Session currentSession = sessionTracker.getOpenSession(); if (currentSession != null) { currentSession.close(); // depends on control dependency: [if], data = [none] } } } }
public class class_name { public static String encode(byte[] a) { // check input if (a == null || a.length == 0) { // bogus shift, no data return "x"; } // determine count int[] cnt = new int[256]; for (int i = 0 ; i < a.length; i++) { cnt[a[i] & 0xff]++; } // determine shift for minimum number of escapes int shift = 1; int nEscapes = a.length; for (int i = 1; i < 256; i++) { if (i == '\'') { continue; } int sum = cnt[i] + cnt[(i + 1) & 0xff] + cnt[(i + '\'') & 0xff]; if (sum < nEscapes) { nEscapes = sum; shift = i; if (nEscapes == 0) { // cannot become smaller break; } } } // construct encoded output int outLen = a.length + nEscapes + 1; StringBuffer out = new StringBuffer(outLen); out.append((char)shift); for (int i = 0; i < a.length; i++) { // apply shift char c = (char)((a[i] - shift)&0xff); // insert escapes if (c == 0) { // forbidden out.append((char)1); out.append((char)1); } else if (c == 1) { // escape character out.append((char)1); out.append((char)2); } else if (c == '\'') { // forbidden out.append((char)1); out.append((char)3); } else { out.append(c); } } return out.toString(); } }
public class class_name { public static String encode(byte[] a) { // check input if (a == null || a.length == 0) { // bogus shift, no data return "x"; // depends on control dependency: [if], data = [none] } // determine count int[] cnt = new int[256]; for (int i = 0 ; i < a.length; i++) { cnt[a[i] & 0xff]++; // depends on control dependency: [for], data = [i] } // determine shift for minimum number of escapes int shift = 1; int nEscapes = a.length; for (int i = 1; i < 256; i++) { if (i == '\'') { continue; } int sum = cnt[i] + cnt[(i + 1) & 0xff] + cnt[(i + '\'') & 0xff]; if (sum < nEscapes) { nEscapes = sum; // depends on control dependency: [if], data = [none] shift = i; // depends on control dependency: [if], data = [none] if (nEscapes == 0) { // cannot become smaller break; } } } // construct encoded output int outLen = a.length + nEscapes + 1; StringBuffer out = new StringBuffer(outLen); out.append((char)shift); for (int i = 0; i < a.length; i++) { // apply shift char c = (char)((a[i] - shift)&0xff); // insert escapes if (c == 0) { // forbidden out.append((char)1); // depends on control dependency: [if], data = [(c] out.append((char)1); // depends on control dependency: [if], data = [(c] } else if (c == 1) { // escape character out.append((char)1); // depends on control dependency: [if], data = [(c] out.append((char)2); // depends on control dependency: [if], data = [(c] } else if (c == '\'') { // forbidden out.append((char)1); // depends on control dependency: [if], data = [(c] out.append((char)3); // depends on control dependency: [if], data = [(c] } else { out.append(c); // depends on control dependency: [if], data = [(c] } } return out.toString(); } }
public class class_name { public void setMaxProgress(int newMaxProgress) { if (getProgress() <= newMaxProgress) { maxProgress = newMaxProgress; } else { throw new IllegalArgumentException( String.format("MaxProgress cant be smaller than the current progress %d<%d", getProgress(), newMaxProgress)); } invalidate(); BootstrapProgressBarGroup parent = (BootstrapProgressBarGroup) getParent(); } }
public class class_name { public void setMaxProgress(int newMaxProgress) { if (getProgress() <= newMaxProgress) { maxProgress = newMaxProgress; // depends on control dependency: [if], data = [none] } else { throw new IllegalArgumentException( String.format("MaxProgress cant be smaller than the current progress %d<%d", getProgress(), newMaxProgress)); } invalidate(); BootstrapProgressBarGroup parent = (BootstrapProgressBarGroup) getParent(); } }
public class class_name { @Nonnull public static String escapeXML(CharSequence s) { // double quote -- quot // ampersand -- amp // less than -- lt // greater than -- gt // apostrophe -- apos StringBuilder sb = new StringBuilder(s.length() * 2); for (int i = 0; i < s.length();) { int codePoint = Character.codePointAt(s, i); if (codePoint == '<') { sb.append(LT); } else if (codePoint == '>') { sb.append(GT); } else if (codePoint == '\"') { sb.append(QUOT); } else if (codePoint == '&') { sb.append(AMP); } else if (codePoint == '\'') { sb.append(APOS); } else { sb.appendCodePoint(codePoint); } i += Character.charCount(codePoint); } return sb.toString(); } }
public class class_name { @Nonnull public static String escapeXML(CharSequence s) { // double quote -- quot // ampersand -- amp // less than -- lt // greater than -- gt // apostrophe -- apos StringBuilder sb = new StringBuilder(s.length() * 2); for (int i = 0; i < s.length();) { int codePoint = Character.codePointAt(s, i); if (codePoint == '<') { sb.append(LT); // depends on control dependency: [if], data = [none] } else if (codePoint == '>') { sb.append(GT); // depends on control dependency: [if], data = [none] } else if (codePoint == '\"') { sb.append(QUOT); // depends on control dependency: [if], data = [none] } else if (codePoint == '&') { sb.append(AMP); // depends on control dependency: [if], data = [none] } else if (codePoint == '\'') { sb.append(APOS); // depends on control dependency: [if], data = [none] } else { sb.appendCodePoint(codePoint); // depends on control dependency: [if], data = [(codePoint] } i += Character.charCount(codePoint); // depends on control dependency: [for], data = [i] } return sb.toString(); } }
public class class_name { public static <T> DelegatingGenericResponse<T> create(T body, Response rawResponse) { if (rawResponse == null) { throw new NullPointerException("rawResponse:null"); } ErrorBody errorBody = null; int code = rawResponse.getStatus(); if (code < 200 || code >= 300) { errorBody = ErrorBody.fromResponse(rawResponse); } return new DelegatingGenericResponse<T>(body, errorBody, rawResponse); } }
public class class_name { public static <T> DelegatingGenericResponse<T> create(T body, Response rawResponse) { if (rawResponse == null) { throw new NullPointerException("rawResponse:null"); } ErrorBody errorBody = null; int code = rawResponse.getStatus(); if (code < 200 || code >= 300) { errorBody = ErrorBody.fromResponse(rawResponse); // depends on control dependency: [if], data = [none] } return new DelegatingGenericResponse<T>(body, errorBody, rawResponse); } }
public class class_name { public Limits withStorageTypes(StorageType... storageTypes) { if (this.storageTypes == null) { setStorageTypes(new java.util.ArrayList<StorageType>(storageTypes.length)); } for (StorageType ele : storageTypes) { this.storageTypes.add(ele); } return this; } }
public class class_name { public Limits withStorageTypes(StorageType... storageTypes) { if (this.storageTypes == null) { setStorageTypes(new java.util.ArrayList<StorageType>(storageTypes.length)); // depends on control dependency: [if], data = [none] } for (StorageType ele : storageTypes) { this.storageTypes.add(ele); // depends on control dependency: [for], data = [ele] } return this; } }
public class class_name { public boolean removeExpire() { try { if(!isBinary)return getJedisCommands(groupName).persist(key) == 1; if(isCluster(groupName)){ return getBinaryJedisClusterCommands(groupName).persist(keyBytes) == 1; } return getBinaryJedisCommands(groupName).persist(keyBytes) == 1; } finally { getJedisProvider(groupName).release(); } } }
public class class_name { public boolean removeExpire() { try { if(!isBinary)return getJedisCommands(groupName).persist(key) == 1; if(isCluster(groupName)){ return getBinaryJedisClusterCommands(groupName).persist(keyBytes) == 1; // depends on control dependency: [if], data = [none] } return getBinaryJedisCommands(groupName).persist(keyBytes) == 1; // depends on control dependency: [try], data = [none] } finally { getJedisProvider(groupName).release(); } } }
public class class_name { public Range<T> intersectionWith(Range<T> other) { if (!this.isOverlappedBy(other)) { throw new IllegalArgumentException(String.format( "Cannot calculate intersection with non-overlapping range %s", other)); } if (this.equals(other)) { return this; } T min = this.comparator.compare(this.min, other.min) < 0 ? other.min : this.min; T max = this.comparator.compare(this.max, other.max) < 0 ? this.max : other.max; return between(min, max, this.comparator); } }
public class class_name { public Range<T> intersectionWith(Range<T> other) { if (!this.isOverlappedBy(other)) { throw new IllegalArgumentException(String.format( "Cannot calculate intersection with non-overlapping range %s", other)); } if (this.equals(other)) { return this; } // depends on control dependency: [if], data = [none] T min = this.comparator.compare(this.min, other.min) < 0 ? other.min : this.min; T max = this.comparator.compare(this.max, other.max) < 0 ? this.max : other.max; return between(min, max, this.comparator); } }
public class class_name { public boolean setCovariance( double a11 , double a12, double a22 ) { Q.data[0] = a11; Q.data[1] = a12; Q.data[2] = a12; Q.data[3] = a22; if( !eigen.decompose(Q) ) { System.err.println("Eigenvalue decomposition failed!"); return false; } Complex_F64 v0 = eigen.getEigenvalue(0); Complex_F64 v1 = eigen.getEigenvalue(1); DMatrixRMaj a0,a1; if( v0.getMagnitude2() > v1.getMagnitude2() ) { a0 = eigen.getEigenVector(0); a1 = eigen.getEigenVector(1); lengthX = (double) v0.getMagnitude(); lengthY = (double) v1.getMagnitude(); } else { a0 = eigen.getEigenVector(1); a1 = eigen.getEigenVector(0); lengthX = (double) v1.getMagnitude(); lengthY = (double) v0.getMagnitude(); } if( a0 == null || a1 == null ) { System.err.println("Complex eigenvalues: "+v0+" "+v1); return false; } lengthX = Math.sqrt(lengthX); lengthY = Math.sqrt(lengthY); x.set( (double) a0.get(0) , (double) a0.get(1)); y.set( (double) a1.get(0) , (double) a1.get(1)); return true; } }
public class class_name { public boolean setCovariance( double a11 , double a12, double a22 ) { Q.data[0] = a11; Q.data[1] = a12; Q.data[2] = a12; Q.data[3] = a22; if( !eigen.decompose(Q) ) { System.err.println("Eigenvalue decomposition failed!"); // depends on control dependency: [if], data = [none] return false; // depends on control dependency: [if], data = [none] } Complex_F64 v0 = eigen.getEigenvalue(0); Complex_F64 v1 = eigen.getEigenvalue(1); DMatrixRMaj a0,a1; if( v0.getMagnitude2() > v1.getMagnitude2() ) { a0 = eigen.getEigenVector(0); // depends on control dependency: [if], data = [none] a1 = eigen.getEigenVector(1); // depends on control dependency: [if], data = [none] lengthX = (double) v0.getMagnitude(); // depends on control dependency: [if], data = [none] lengthY = (double) v1.getMagnitude(); // depends on control dependency: [if], data = [none] } else { a0 = eigen.getEigenVector(1); // depends on control dependency: [if], data = [none] a1 = eigen.getEigenVector(0); // depends on control dependency: [if], data = [none] lengthX = (double) v1.getMagnitude(); // depends on control dependency: [if], data = [none] lengthY = (double) v0.getMagnitude(); // depends on control dependency: [if], data = [none] } if( a0 == null || a1 == null ) { System.err.println("Complex eigenvalues: "+v0+" "+v1); // depends on control dependency: [if], data = [none] return false; // depends on control dependency: [if], data = [none] } lengthX = Math.sqrt(lengthX); lengthY = Math.sqrt(lengthY); x.set( (double) a0.get(0) , (double) a0.get(1)); y.set( (double) a1.get(0) , (double) a1.get(1)); return true; } }
public class class_name { public void fieldsToControls() { super.fieldsToControls(); for (int iRowIndex = 0; iRowIndex < m_vComponentCache.size(); iRowIndex++) { ComponentCache componentCache = (ComponentCache)m_vComponentCache.elementAt(iRowIndex); if (componentCache != null) { // Move the data to the model for (int iColumnIndex = 0; iColumnIndex < componentCache.m_rgcompoments.length; iColumnIndex++) { this.fieldToData(componentCache, iRowIndex, iColumnIndex); } } } } }
public class class_name { public void fieldsToControls() { super.fieldsToControls(); for (int iRowIndex = 0; iRowIndex < m_vComponentCache.size(); iRowIndex++) { ComponentCache componentCache = (ComponentCache)m_vComponentCache.elementAt(iRowIndex); if (componentCache != null) { // Move the data to the model for (int iColumnIndex = 0; iColumnIndex < componentCache.m_rgcompoments.length; iColumnIndex++) { this.fieldToData(componentCache, iRowIndex, iColumnIndex); // depends on control dependency: [for], data = [iColumnIndex] } } } } }
public class class_name { public final void print(CharSequence separator, int charsPerLine) { boolean first = true; int len = 0; for (T v : this) { String s = String.valueOf(v); if (first) { System.out.print(s); len += s.length(); first = false; } else { System.out.print(separator); len += separator.length(); if (len > charsPerLine) { System.out.println(); System.out.print(s); len = s.length(); } else { System.out.print(s); len += s.length(); } } } } }
public class class_name { public final void print(CharSequence separator, int charsPerLine) { boolean first = true; int len = 0; for (T v : this) { String s = String.valueOf(v); if (first) { System.out.print(s); // depends on control dependency: [if], data = [none] len += s.length(); // depends on control dependency: [if], data = [none] first = false; // depends on control dependency: [if], data = [none] } else { System.out.print(separator); // depends on control dependency: [if], data = [none] len += separator.length(); // depends on control dependency: [if], data = [none] if (len > charsPerLine) { System.out.println(); // depends on control dependency: [if], data = [none] System.out.print(s); // depends on control dependency: [if], data = [none] len = s.length(); // depends on control dependency: [if], data = [none] } else { System.out.print(s); // depends on control dependency: [if], data = [none] len += s.length(); // depends on control dependency: [if], data = [none] } } } } }
public class class_name { public void marshall(GetIPSetRequest getIPSetRequest, ProtocolMarshaller protocolMarshaller) { if (getIPSetRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(getIPSetRequest.getDetectorId(), DETECTORID_BINDING); protocolMarshaller.marshall(getIPSetRequest.getIpSetId(), IPSETID_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } } }
public class class_name { public void marshall(GetIPSetRequest getIPSetRequest, ProtocolMarshaller protocolMarshaller) { if (getIPSetRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(getIPSetRequest.getDetectorId(), DETECTORID_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(getIPSetRequest.getIpSetId(), IPSETID_BINDING); // depends on control dependency: [try], data = [none] } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public static Float stringToFloat(String strString, int ibScale) throws Exception { Number objData; initGlobals(); // Make sure you have the utilities if ((strString == null) || (strString.equals(Constant.BLANK))) return null; strString = DataConverters.stripNonNumber(strString); try { synchronized (gNumberFormat) { objData = gNumberFormat.parse(strString); } if (!(objData instanceof Float)) { if (objData instanceof Number) objData = new Float(objData.floatValue()); else objData = null; } } catch (ParseException ex) { objData = null; } if (objData == null) { try { objData = new Float(strString); } catch (NumberFormatException ex) { throw ex; } } if (ibScale != -1) objData = new Float(Math.floor(((Float)objData).floatValue() * Math.pow(10, ibScale) + 0.5) / Math.pow(10, ibScale)); return (Float)objData; } }
public class class_name { public static Float stringToFloat(String strString, int ibScale) throws Exception { Number objData; initGlobals(); // Make sure you have the utilities if ((strString == null) || (strString.equals(Constant.BLANK))) return null; strString = DataConverters.stripNonNumber(strString); try { synchronized (gNumberFormat) { objData = gNumberFormat.parse(strString); } if (!(objData instanceof Float)) { if (objData instanceof Number) objData = new Float(objData.floatValue()); else objData = null; } } catch (ParseException ex) { objData = null; } if (objData == null) { try { objData = new Float(strString); // depends on control dependency: [try], data = [none] } catch (NumberFormatException ex) { throw ex; } // depends on control dependency: [catch], data = [none] } if (ibScale != -1) objData = new Float(Math.floor(((Float)objData).floatValue() * Math.pow(10, ibScale) + 0.5) / Math.pow(10, ibScale)); return (Float)objData; } }
public class class_name { public void detachAll(final Object self, final boolean nonProxiedInstance, final Map<Object, Object> alreadyDetached, final Map<Object, Object> lazyObjects) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { final Class<?> selfClass = self.getClass(); for (String fieldName : doc.fieldNames()) { final Field field = OObjectEntitySerializer.getField(fieldName, selfClass); if (field != null) { Object value = getValue(self, fieldName, false, null, true); if (value instanceof OObjectLazyMultivalueElement) { ((OObjectLazyMultivalueElement<?>) value).detachAll(nonProxiedInstance, alreadyDetached, lazyObjects); if (nonProxiedInstance) value = ((OObjectLazyMultivalueElement<?>) value).getNonOrientInstance(); } else if (value instanceof Proxy) { OObjectProxyMethodHandler handler = (OObjectProxyMethodHandler) ((ProxyObject) value).getHandler(); if (nonProxiedInstance) { value = OObjectEntitySerializer.getNonProxiedInstance(value); } if (OObjectEntitySerializer.isFetchLazyField(self.getClass(), fieldName)) { // just make a placeholder with only the id, so it can be fetched later (but not by orient // internally) // do not use the already detached map for this, that might mix up lazy and non-lazy objects Object lazyValue = lazyObjects.get(handler.doc.getIdentity()); if (lazyValue != null) { value = lazyValue; } else { OObjectEntitySerializer.setIdField(field.getType(), value, handler.doc.getIdentity()); lazyObjects.put(handler.doc.getIdentity(), value); } } else { Object detachedValue = alreadyDetached.get(handler.doc.getIdentity()); if (detachedValue != null) { value = detachedValue; } else { ORID identity = handler.doc.getIdentity(); if (identity.isValid()) alreadyDetached.put(identity, value); handler.detachAll(value, nonProxiedInstance, alreadyDetached, lazyObjects); } } } else if (value instanceof OTrackedMap && nonProxiedInstance) { Map newValue = new LinkedHashMap<>(); newValue.putAll((Map) value); value = newValue; } else if (value instanceof OTrackedList && nonProxiedInstance) { List newValue = new ArrayList(); newValue.addAll((Collection) value); value = newValue; } else if (value instanceof OTrackedSet && nonProxiedInstance) { Set newValue = new LinkedHashSet(); newValue.addAll((Collection) value); value = newValue; } OObjectEntitySerializer.setFieldValue(field, self, value); } } OObjectEntitySerializer.setIdField(selfClass, self, doc.getIdentity()); OObjectEntitySerializer.setVersionField(selfClass, self, doc.getVersion()); } }
public class class_name { public void detachAll(final Object self, final boolean nonProxiedInstance, final Map<Object, Object> alreadyDetached, final Map<Object, Object> lazyObjects) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { final Class<?> selfClass = self.getClass(); for (String fieldName : doc.fieldNames()) { final Field field = OObjectEntitySerializer.getField(fieldName, selfClass); if (field != null) { Object value = getValue(self, fieldName, false, null, true); if (value instanceof OObjectLazyMultivalueElement) { ((OObjectLazyMultivalueElement<?>) value).detachAll(nonProxiedInstance, alreadyDetached, lazyObjects); // depends on control dependency: [if], data = [none] if (nonProxiedInstance) value = ((OObjectLazyMultivalueElement<?>) value).getNonOrientInstance(); } else if (value instanceof Proxy) { OObjectProxyMethodHandler handler = (OObjectProxyMethodHandler) ((ProxyObject) value).getHandler(); if (nonProxiedInstance) { value = OObjectEntitySerializer.getNonProxiedInstance(value); // depends on control dependency: [if], data = [none] } if (OObjectEntitySerializer.isFetchLazyField(self.getClass(), fieldName)) { // just make a placeholder with only the id, so it can be fetched later (but not by orient // internally) // do not use the already detached map for this, that might mix up lazy and non-lazy objects Object lazyValue = lazyObjects.get(handler.doc.getIdentity()); if (lazyValue != null) { value = lazyValue; // depends on control dependency: [if], data = [none] } else { OObjectEntitySerializer.setIdField(field.getType(), value, handler.doc.getIdentity()); // depends on control dependency: [if], data = [none] lazyObjects.put(handler.doc.getIdentity(), value); // depends on control dependency: [if], data = [none] } } else { Object detachedValue = alreadyDetached.get(handler.doc.getIdentity()); if (detachedValue != null) { value = detachedValue; // depends on control dependency: [if], data = [none] } else { ORID identity = handler.doc.getIdentity(); if (identity.isValid()) alreadyDetached.put(identity, value); handler.detachAll(value, nonProxiedInstance, alreadyDetached, lazyObjects); // depends on control dependency: [if], data = [none] } } } else if (value instanceof OTrackedMap && nonProxiedInstance) { Map newValue = new LinkedHashMap<>(); newValue.putAll((Map) value); // depends on control dependency: [if], data = [none] value = newValue; // depends on control dependency: [if], data = [none] } else if (value instanceof OTrackedList && nonProxiedInstance) { List newValue = new ArrayList(); newValue.addAll((Collection) value); // depends on control dependency: [if], data = [none] value = newValue; // depends on control dependency: [if], data = [none] } else if (value instanceof OTrackedSet && nonProxiedInstance) { Set newValue = new LinkedHashSet(); newValue.addAll((Collection) value); // depends on control dependency: [if], data = [none] value = newValue; // depends on control dependency: [if], data = [none] } OObjectEntitySerializer.setFieldValue(field, self, value); } } OObjectEntitySerializer.setIdField(selfClass, self, doc.getIdentity()); OObjectEntitySerializer.setVersionField(selfClass, self, doc.getVersion()); } }
public class class_name { private static int buildTreeNode(FastRandomTree node, int nodeId, Node parentPMMLNode) { Instances instance = node.m_MotherForest.m_Info; addScoreDistribution(parentPMMLNode, node.m_ClassProbs, instance); if (node.m_Attribute == -1) { // Leaf: Add the node's score. parentPMMLNode.withScore(leafScoreFromDistribution(node.m_ClassProbs, instance)); return nodeId; } Attribute attribute = instance.attribute(node.m_Attribute); if (attribute.isNominal()) { return buildNominalNode(attribute, node, nodeId, parentPMMLNode); } else if (attribute.isNumeric()) { return buildNumericNode(attribute, node, nodeId, parentPMMLNode); } else { throw new RuntimeException("Unsupported attribute type for: " + attribute); } } }
public class class_name { private static int buildTreeNode(FastRandomTree node, int nodeId, Node parentPMMLNode) { Instances instance = node.m_MotherForest.m_Info; addScoreDistribution(parentPMMLNode, node.m_ClassProbs, instance); if (node.m_Attribute == -1) { // Leaf: Add the node's score. parentPMMLNode.withScore(leafScoreFromDistribution(node.m_ClassProbs, instance)); // depends on control dependency: [if], data = [none] return nodeId; // depends on control dependency: [if], data = [none] } Attribute attribute = instance.attribute(node.m_Attribute); if (attribute.isNominal()) { return buildNominalNode(attribute, node, nodeId, parentPMMLNode); // depends on control dependency: [if], data = [none] } else if (attribute.isNumeric()) { return buildNumericNode(attribute, node, nodeId, parentPMMLNode); // depends on control dependency: [if], data = [none] } else { throw new RuntimeException("Unsupported attribute type for: " + attribute); } } }
public class class_name { @Override public InternalResourceProvider doCreateResourceProvider(String rootPath) { try { return new FileResourceProvider(new File(_root, rootPath)); } catch(IOException e) { throw new RuntimeException(e); } } }
public class class_name { @Override public InternalResourceProvider doCreateResourceProvider(String rootPath) { try { return new FileResourceProvider(new File(_root, rootPath)); // depends on control dependency: [try], data = [none] } catch(IOException e) { throw new RuntimeException(e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { @Programmatic public List<NotableLink> findByNotableInDateRange( final Object notable, final LocalDate startDate, final LocalDate endDate) { if(notable == null) { return null; } final Bookmark bookmark = bookmarkService.bookmarkFor(notable); if(bookmark == null) { return null; } if(startDate == null) { return null; } if(endDate == null) { return null; } final String notableStr = bookmark.toString(); return repositoryService.allMatches( new QueryDefault<>(NotableLink.class, "findByNotableInDateRange", "notableStr", notableStr, "startDate", startDate, "endDate", endDate)); } }
public class class_name { @Programmatic public List<NotableLink> findByNotableInDateRange( final Object notable, final LocalDate startDate, final LocalDate endDate) { if(notable == null) { return null; // depends on control dependency: [if], data = [none] } final Bookmark bookmark = bookmarkService.bookmarkFor(notable); if(bookmark == null) { return null; // depends on control dependency: [if], data = [none] } if(startDate == null) { return null; // depends on control dependency: [if], data = [none] } if(endDate == null) { return null; // depends on control dependency: [if], data = [none] } final String notableStr = bookmark.toString(); return repositoryService.allMatches( new QueryDefault<>(NotableLink.class, "findByNotableInDateRange", "notableStr", notableStr, "startDate", startDate, "endDate", endDate)); } }
public class class_name { private void writeTitleProperty(Node node, Hashtable properties) { String title = ""; // the title string is stored in the first child node NodeList children = node.getChildNodes(); if (children != null) { Node titleNode = children.item(0); if (titleNode != null) { title = titleNode.getNodeValue(); } } // add the title property if we have one if ((title != null) && (title.length() > 0)) { properties.put(CmsPropertyDefinition.PROPERTY_TITLE, CmsStringUtil.substitute(title, "{subst}", "&#")); // the title will be used as navtext if no other navtext is // given if (properties.get(CmsPropertyDefinition.PROPERTY_NAVTEXT) == null) { properties.put( CmsPropertyDefinition.PROPERTY_NAVTEXT, CmsStringUtil.substitute(title, "{subst}", "&#")); } } } }
public class class_name { private void writeTitleProperty(Node node, Hashtable properties) { String title = ""; // the title string is stored in the first child node NodeList children = node.getChildNodes(); if (children != null) { Node titleNode = children.item(0); if (titleNode != null) { title = titleNode.getNodeValue(); // depends on control dependency: [if], data = [none] } } // add the title property if we have one if ((title != null) && (title.length() > 0)) { properties.put(CmsPropertyDefinition.PROPERTY_TITLE, CmsStringUtil.substitute(title, "{subst}", "&#")); // depends on control dependency: [if], data = [none] // the title will be used as navtext if no other navtext is // given if (properties.get(CmsPropertyDefinition.PROPERTY_NAVTEXT) == null) { properties.put( CmsPropertyDefinition.PROPERTY_NAVTEXT, CmsStringUtil.substitute(title, "{subst}", "&#")); // depends on control dependency: [if], data = [none] } } } }
public class class_name { public XmlWrapperSerializer createSerializer(Writer output) { try { XMLSerializer xmlStreamWriter=new XMLSerializer(output); return new XmlWrapperSerializer(xmlStreamWriter); } catch (Exception e) { e.printStackTrace(); throw new KriptonRuntimeException(e); } } }
public class class_name { public XmlWrapperSerializer createSerializer(Writer output) { try { XMLSerializer xmlStreamWriter=new XMLSerializer(output); return new XmlWrapperSerializer(xmlStreamWriter); // depends on control dependency: [try], data = [none] } catch (Exception e) { e.printStackTrace(); throw new KriptonRuntimeException(e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public List<T> getPlugins() { if (!initialized) { this.plugins = initialize(this.plugins); this.initialized = true; } return plugins; } }
public class class_name { public List<T> getPlugins() { if (!initialized) { this.plugins = initialize(this.plugins); // depends on control dependency: [if], data = [none] this.initialized = true; // depends on control dependency: [if], data = [none] } return plugins; } }
public class class_name { public List<R> getRuns() { List<R> resultList = new ArrayList<>(); for (IndexedRun run : runs) { resultList.add(run.getRun()); } return resultList; } }
public class class_name { public List<R> getRuns() { List<R> resultList = new ArrayList<>(); for (IndexedRun run : runs) { resultList.add(run.getRun()); // depends on control dependency: [for], data = [run] } return resultList; } }
public class class_name { private boolean cancelRequestInternal( AORequestedTick requestedTick, boolean expiry) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry( tc, "cancelRequestInternal", new Object[] { requestedTick, Boolean.valueOf(expiry)}); // cancel the timer only if !expiry, since expiry implies timer has already occured. boolean transitionOccured = requestedTick.expire(!expiry); if (transitionOccured) { // successfully expired listOfRequests.remove(requestedTick); tableOfRequests.remove(requestedTick.objTick); // start the idle timer if no element left in listOfRequests // and set isready to false if (listOfRequests.isEmpty()) { if (idleTimeout > 0) this.idleHandler = am.create(idleTimeout, this); if (isready) { isready = false; ck.notReady(); } } } // end if (transitionOccured) if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "cancelRequestInternal", Boolean.valueOf(transitionOccured)); return transitionOccured; } }
public class class_name { private boolean cancelRequestInternal( AORequestedTick requestedTick, boolean expiry) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry( tc, "cancelRequestInternal", new Object[] { requestedTick, Boolean.valueOf(expiry)}); // cancel the timer only if !expiry, since expiry implies timer has already occured. boolean transitionOccured = requestedTick.expire(!expiry); if (transitionOccured) { // successfully expired listOfRequests.remove(requestedTick); // depends on control dependency: [if], data = [none] tableOfRequests.remove(requestedTick.objTick); // depends on control dependency: [if], data = [none] // start the idle timer if no element left in listOfRequests // and set isready to false if (listOfRequests.isEmpty()) { if (idleTimeout > 0) this.idleHandler = am.create(idleTimeout, this); if (isready) { isready = false; // depends on control dependency: [if], data = [none] ck.notReady(); // depends on control dependency: [if], data = [none] } } } // end if (transitionOccured) if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "cancelRequestInternal", Boolean.valueOf(transitionOccured)); return transitionOccured; } }
public class class_name { public String scanName() throws IOException { // load more characters, if needed if (fCurrentEntity.position == fCurrentEntity.count) { load(0, true); } // scan name int offset = fCurrentEntity.position; if (XMLChar.isNameStart(fCurrentEntity.ch[offset])) { if (++fCurrentEntity.position == fCurrentEntity.count) { fCurrentEntity.ch[0] = fCurrentEntity.ch[offset]; offset = 0; if (load(1, false)) { fCurrentEntity.columnNumber++; String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1); return symbol; } } while (XMLChar.isName(fCurrentEntity.ch[fCurrentEntity.position])) { if (++fCurrentEntity.position == fCurrentEntity.count) { int length = fCurrentEntity.position - offset; if (length == fBufferSize) { // bad luck we have to resize our buffer char[] tmp = new char[fBufferSize * 2]; System.arraycopy(fCurrentEntity.ch, offset, tmp, 0, length); fCurrentEntity.ch = tmp; fBufferSize *= 2; } else { System.arraycopy(fCurrentEntity.ch, offset, fCurrentEntity.ch, 0, length); } offset = 0; if (load(length, false)) { break; } } } } int length = fCurrentEntity.position - offset; fCurrentEntity.columnNumber += length; // return name String symbol = null; if (length > 0) { symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, offset, length); } return symbol; } }
public class class_name { public String scanName() throws IOException { // load more characters, if needed if (fCurrentEntity.position == fCurrentEntity.count) { load(0, true); } // scan name int offset = fCurrentEntity.position; if (XMLChar.isNameStart(fCurrentEntity.ch[offset])) { if (++fCurrentEntity.position == fCurrentEntity.count) { fCurrentEntity.ch[0] = fCurrentEntity.ch[offset]; // depends on control dependency: [if], data = [none] offset = 0; // depends on control dependency: [if], data = [none] if (load(1, false)) { fCurrentEntity.columnNumber++; // depends on control dependency: [if], data = [none] String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1); return symbol; // depends on control dependency: [if], data = [none] } } while (XMLChar.isName(fCurrentEntity.ch[fCurrentEntity.position])) { if (++fCurrentEntity.position == fCurrentEntity.count) { int length = fCurrentEntity.position - offset; if (length == fBufferSize) { // bad luck we have to resize our buffer char[] tmp = new char[fBufferSize * 2]; System.arraycopy(fCurrentEntity.ch, offset, tmp, 0, length); // depends on control dependency: [if], data = [none] fCurrentEntity.ch = tmp; // depends on control dependency: [if], data = [none] fBufferSize *= 2; // depends on control dependency: [if], data = [none] } else { System.arraycopy(fCurrentEntity.ch, offset, fCurrentEntity.ch, 0, length); // depends on control dependency: [if], data = [none] } offset = 0; // depends on control dependency: [if], data = [none] if (load(length, false)) { break; } } } } int length = fCurrentEntity.position - offset; fCurrentEntity.columnNumber += length; // return name String symbol = null; if (length > 0) { symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, offset, length); } return symbol; } }
public class class_name { public static ExpectedCondition<WebElement> atLeastOneOfTheseElementsIsPresent(final By... locators) { return new ExpectedCondition<WebElement>() { @Override public WebElement apply(@Nullable WebDriver driver) { WebElement element = null; if (driver != null && locators.length > 0) { for (final By b : locators) { try { element = driver.findElement(b); break; } catch (final Exception e) { } } } return element; } }; } }
public class class_name { public static ExpectedCondition<WebElement> atLeastOneOfTheseElementsIsPresent(final By... locators) { return new ExpectedCondition<WebElement>() { @Override public WebElement apply(@Nullable WebDriver driver) { WebElement element = null; if (driver != null && locators.length > 0) { for (final By b : locators) { try { element = driver.findElement(b); // depends on control dependency: [try], data = [none] break; } catch (final Exception e) { } // depends on control dependency: [catch], data = [none] } } return element; } }; } }
public class class_name { public static String addFolderSlashIfNeeded(String folderName) { if (!"".equals(folderName) && !folderName.endsWith("/")) { return folderName + "/"; } else { return folderName; } } }
public class class_name { public static String addFolderSlashIfNeeded(String folderName) { if (!"".equals(folderName) && !folderName.endsWith("/")) { return folderName + "/"; // depends on control dependency: [if], data = [none] } else { return folderName; // depends on control dependency: [if], data = [none] } } }
public class class_name { public static String interpolate(File dockerFile, FixedStringSearchInterpolator interpolator) throws IOException { StringBuilder ret = new StringBuilder(); try (BufferedReader reader = new BufferedReader(new FileReader(dockerFile))) { String line; while ((line = reader.readLine()) != null) { ret.append(interpolator.interpolate(line)).append(System.lineSeparator()); } } return ret.toString(); } }
public class class_name { public static String interpolate(File dockerFile, FixedStringSearchInterpolator interpolator) throws IOException { StringBuilder ret = new StringBuilder(); try (BufferedReader reader = new BufferedReader(new FileReader(dockerFile))) { String line; while ((line = reader.readLine()) != null) { ret.append(interpolator.interpolate(line)).append(System.lineSeparator()); // depends on control dependency: [while], data = [none] } } return ret.toString(); } }
public class class_name { private RelBuilder createSelectDistinct(RelBuilder relBuilder, Aggregate aggregate, List<Integer> argList, int filterArg, Map<Integer, Integer> sourceOf) { relBuilder.push(aggregate.getInput()); final List<Pair<RexNode, String>> projects = new ArrayList<>(); final List<RelDataTypeField> childFields = relBuilder.peek().getRowType().getFieldList(); for (int i : aggregate.getGroupSet()) { sourceOf.put(i, projects.size()); projects.add(RexInputRef.of2(i, childFields)); } if (filterArg >= 0) { sourceOf.put(filterArg, projects.size()); projects.add(RexInputRef.of2(filterArg, childFields)); } for (Integer arg : argList) { if (filterArg >= 0) { // Implement // agg(DISTINCT arg) FILTER $f // by generating // SELECT DISTINCT ... CASE WHEN $f THEN arg ELSE NULL END AS arg // and then applying // agg(arg) // as usual. // // It works except for (rare) agg functions that need to see null // values. final RexBuilder rexBuilder = aggregate.getCluster().getRexBuilder(); final RexInputRef filterRef = RexInputRef.of(filterArg, childFields); final Pair<RexNode, String> argRef = RexInputRef.of2(arg, childFields); RexNode condition = rexBuilder.makeCall(SqlStdOperatorTable.CASE, filterRef, argRef.left, rexBuilder.ensureType(argRef.left.getType(), rexBuilder.makeCast(argRef.left.getType(), rexBuilder.constantNull()), true)); sourceOf.put(arg, projects.size()); projects.add(Pair.of(condition, "i$" + argRef.right)); continue; } if (sourceOf.get(arg) != null) { continue; } sourceOf.put(arg, projects.size()); projects.add(RexInputRef.of2(arg, childFields)); } relBuilder.project(Pair.left(projects), Pair.right(projects)); // Get the distinct values of the GROUP BY fields and the arguments // to the agg functions. relBuilder.push( aggregate.copy(aggregate.getTraitSet(), relBuilder.build(), false, ImmutableBitSet.range(projects.size()), null, com.google.common.collect.ImmutableList.<AggregateCall>of())); return relBuilder; } }
public class class_name { private RelBuilder createSelectDistinct(RelBuilder relBuilder, Aggregate aggregate, List<Integer> argList, int filterArg, Map<Integer, Integer> sourceOf) { relBuilder.push(aggregate.getInput()); final List<Pair<RexNode, String>> projects = new ArrayList<>(); final List<RelDataTypeField> childFields = relBuilder.peek().getRowType().getFieldList(); for (int i : aggregate.getGroupSet()) { sourceOf.put(i, projects.size()); // depends on control dependency: [for], data = [i] projects.add(RexInputRef.of2(i, childFields)); // depends on control dependency: [for], data = [i] } if (filterArg >= 0) { sourceOf.put(filterArg, projects.size()); // depends on control dependency: [if], data = [(filterArg] projects.add(RexInputRef.of2(filterArg, childFields)); // depends on control dependency: [if], data = [(filterArg] } for (Integer arg : argList) { if (filterArg >= 0) { // Implement // agg(DISTINCT arg) FILTER $f // by generating // SELECT DISTINCT ... CASE WHEN $f THEN arg ELSE NULL END AS arg // and then applying // agg(arg) // as usual. // // It works except for (rare) agg functions that need to see null // values. final RexBuilder rexBuilder = aggregate.getCluster().getRexBuilder(); final RexInputRef filterRef = RexInputRef.of(filterArg, childFields); final Pair<RexNode, String> argRef = RexInputRef.of2(arg, childFields); RexNode condition = rexBuilder.makeCall(SqlStdOperatorTable.CASE, filterRef, argRef.left, rexBuilder.ensureType(argRef.left.getType(), rexBuilder.makeCast(argRef.left.getType(), rexBuilder.constantNull()), true)); sourceOf.put(arg, projects.size()); // depends on control dependency: [if], data = [none] projects.add(Pair.of(condition, "i$" + argRef.right)); // depends on control dependency: [if], data = [none] continue; } if (sourceOf.get(arg) != null) { continue; } sourceOf.put(arg, projects.size()); // depends on control dependency: [for], data = [arg] projects.add(RexInputRef.of2(arg, childFields)); // depends on control dependency: [for], data = [arg] } relBuilder.project(Pair.left(projects), Pair.right(projects)); // Get the distinct values of the GROUP BY fields and the arguments // to the agg functions. relBuilder.push( aggregate.copy(aggregate.getTraitSet(), relBuilder.build(), false, ImmutableBitSet.range(projects.size()), null, com.google.common.collect.ImmutableList.<AggregateCall>of())); return relBuilder; } }
public class class_name { public LifecycleCallbackType<InterceptorType<T>> getOrCreatePostConstruct() { List<Node> nodeList = childNode.get("post-construct"); if (nodeList != null && nodeList.size() > 0) { return new LifecycleCallbackTypeImpl<InterceptorType<T>>(this, "post-construct", childNode, nodeList.get(0)); } return createPostConstruct(); } }
public class class_name { public LifecycleCallbackType<InterceptorType<T>> getOrCreatePostConstruct() { List<Node> nodeList = childNode.get("post-construct"); if (nodeList != null && nodeList.size() > 0) { return new LifecycleCallbackTypeImpl<InterceptorType<T>>(this, "post-construct", childNode, nodeList.get(0)); // depends on control dependency: [if], data = [none] } return createPostConstruct(); } }
public class class_name { @SuppressWarnings("unchecked") public final T duplicate() { if (backing instanceof ByteBuffer) { return (T) ((ByteBuffer) backing).duplicate(); } if (backing instanceof CharBuffer) { return (T) ((CharBuffer) backing).duplicate(); } throw new IllegalArgumentException("Backing buffer of unknown type."); } }
public class class_name { @SuppressWarnings("unchecked") public final T duplicate() { if (backing instanceof ByteBuffer) { return (T) ((ByteBuffer) backing).duplicate(); // depends on control dependency: [if], data = [none] } if (backing instanceof CharBuffer) { return (T) ((CharBuffer) backing).duplicate(); // depends on control dependency: [if], data = [none] } throw new IllegalArgumentException("Backing buffer of unknown type."); } }
public class class_name { static String stripLeadingHyphens(String str) { if (str == null) { return null; } if (str.startsWith("--")) { return str.substring(2, str.length()); } else if (str.startsWith("-")) { return str.substring(1, str.length()); } return str; } }
public class class_name { static String stripLeadingHyphens(String str) { if (str == null) { return null; // depends on control dependency: [if], data = [none] } if (str.startsWith("--")) { return str.substring(2, str.length()); // depends on control dependency: [if], data = [none] } else if (str.startsWith("-")) { return str.substring(1, str.length()); // depends on control dependency: [if], data = [none] } return str; } }
public class class_name { public void setAttachedPolicies(java.util.Collection<AttachedPolicy> attachedPolicies) { if (attachedPolicies == null) { this.attachedPolicies = null; return; } this.attachedPolicies = new com.amazonaws.internal.SdkInternalList<AttachedPolicy>(attachedPolicies); } }
public class class_name { public void setAttachedPolicies(java.util.Collection<AttachedPolicy> attachedPolicies) { if (attachedPolicies == null) { this.attachedPolicies = null; // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } this.attachedPolicies = new com.amazonaws.internal.SdkInternalList<AttachedPolicy>(attachedPolicies); } }
public class class_name { public static List<BundleModel> bundles(BundleContext context) { List<BundleModel> bundles = new ArrayList<>(); for (Bundle bundle : context.getBundles()) { bundles.add(new BundleModel(bundle)); } return bundles; } }
public class class_name { public static List<BundleModel> bundles(BundleContext context) { List<BundleModel> bundles = new ArrayList<>(); for (Bundle bundle : context.getBundles()) { bundles.add(new BundleModel(bundle)); // depends on control dependency: [for], data = [bundle] } return bundles; } }
public class class_name { public static String join(String[] strings, String separator) { if (strings == null || strings.length == 0) { return EMPTY; } StringBuilder sb = new StringBuilder(); for (String string : strings) { if (isNotBlank(string)) { sb.append(string).append(separator); } } return sb.length() > 0 ? sb.substring(0, sb.length() - separator.length()) : StringUtils.EMPTY; } }
public class class_name { public static String join(String[] strings, String separator) { if (strings == null || strings.length == 0) { return EMPTY; // depends on control dependency: [if], data = [none] } StringBuilder sb = new StringBuilder(); for (String string : strings) { if (isNotBlank(string)) { sb.append(string).append(separator); // depends on control dependency: [if], data = [none] } } return sb.length() > 0 ? sb.substring(0, sb.length() - separator.length()) : StringUtils.EMPTY; } }
public class class_name { public UNode toDoc() { UNode userNode = UNode.createMapNode(m_userID, "user"); if (!Utils.isEmpty(m_password)) { userNode.addValueNode("password", m_password, true); } if (!Utils.isEmpty(m_hash)) { userNode.addValueNode("hash", m_hash, true); } String permissions = "ALL"; if (m_permissions.size() > 0) { permissions = Utils.concatenate(m_permissions, ","); } userNode.addValueNode("permissions", permissions); return userNode; } }
public class class_name { public UNode toDoc() { UNode userNode = UNode.createMapNode(m_userID, "user"); if (!Utils.isEmpty(m_password)) { userNode.addValueNode("password", m_password, true); // depends on control dependency: [if], data = [none] } if (!Utils.isEmpty(m_hash)) { userNode.addValueNode("hash", m_hash, true); // depends on control dependency: [if], data = [none] } String permissions = "ALL"; if (m_permissions.size() > 0) { permissions = Utils.concatenate(m_permissions, ","); // depends on control dependency: [if], data = [none] } userNode.addValueNode("permissions", permissions); return userNode; } }
public class class_name { public void setSearchFilter(String searchFilter) { if (!m_metadata.isSearchable()) { return; } if (searchFilter == null) { searchFilter = ""; } m_searchFilter = searchFilter; boolean showAll = CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_searchFilter); getMetadata().getSearchAction().getShowAllAction().setVisible(showAll); if (!m_metadata.isSelfManaged()) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(searchFilter)) { // reset content if filter is empty m_filteredItems = null; } else { m_filteredItems = getMetadata().getSearchAction().filter(getAllContent(), m_searchFilter); } } String sCol = m_sortedColumn; m_sortedColumn = ""; if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(sCol)) { CmsListOrderEnum order = getCurrentSortOrder(); setSortedColumn(sCol); if (order == CmsListOrderEnum.ORDER_DESCENDING) { setSortedColumn(sCol); } } setCurrentPage(1); } }
public class class_name { public void setSearchFilter(String searchFilter) { if (!m_metadata.isSearchable()) { return; // depends on control dependency: [if], data = [none] } if (searchFilter == null) { searchFilter = ""; // depends on control dependency: [if], data = [none] } m_searchFilter = searchFilter; boolean showAll = CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_searchFilter); getMetadata().getSearchAction().getShowAllAction().setVisible(showAll); if (!m_metadata.isSelfManaged()) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(searchFilter)) { // reset content if filter is empty m_filteredItems = null; // depends on control dependency: [if], data = [none] } else { m_filteredItems = getMetadata().getSearchAction().filter(getAllContent(), m_searchFilter); // depends on control dependency: [if], data = [none] } } String sCol = m_sortedColumn; m_sortedColumn = ""; if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(sCol)) { CmsListOrderEnum order = getCurrentSortOrder(); setSortedColumn(sCol); // depends on control dependency: [if], data = [none] if (order == CmsListOrderEnum.ORDER_DESCENDING) { setSortedColumn(sCol); // depends on control dependency: [if], data = [none] } } setCurrentPage(1); } }
public class class_name { public static Object convertToArray(Object source, Class<?> target) throws ConversionException { try { Class<?> targetType = target.getComponentType(); if (source.getClass().isArray()) { Object targetInstance = Array.newInstance(targetType, Array.getLength(source)); for (int i = 0; i < Array.getLength(source); i++) { Array.set(targetInstance, i, convert(Array.get(source, i), targetType)); } return targetInstance; } if (source instanceof Collection<?>) { Collection<?> sourceCollection = (Collection<?>) source; Object targetInstance = Array.newInstance(target.getComponentType(), sourceCollection.size()); Iterator<?> it = sourceCollection.iterator(); int i = 0; while (it.hasNext()) { Array.set(targetInstance, i++, convert(it.next(), targetType)); } return targetInstance; } throw new ConversionException("Unable to convert to array"); } catch (Exception ex) { throw new ConversionException("Error converting to array", ex); } } }
public class class_name { public static Object convertToArray(Object source, Class<?> target) throws ConversionException { try { Class<?> targetType = target.getComponentType(); if (source.getClass().isArray()) { Object targetInstance = Array.newInstance(targetType, Array.getLength(source)); for (int i = 0; i < Array.getLength(source); i++) { Array.set(targetInstance, i, convert(Array.get(source, i), targetType)); } return targetInstance; } if (source instanceof Collection<?>) { Collection<?> sourceCollection = (Collection<?>) source; Object targetInstance = Array.newInstance(target.getComponentType(), sourceCollection.size()); Iterator<?> it = sourceCollection.iterator(); int i = 0; while (it.hasNext()) { Array.set(targetInstance, i++, convert(it.next(), targetType)); // depends on control dependency: [while], data = [none] } return targetInstance; } throw new ConversionException("Unable to convert to array"); } catch (Exception ex) { throw new ConversionException("Error converting to array", ex); } } }
public class class_name { private Set<File> getReadLocks() { final Set<File> readLocks = new HashSet<File>(); File[] lckFiles = this.lockPath.listFiles(lockFilter); for (final File lckFile : lckFiles) { if (lockFilter.isReaderLockFile(lckFile)) { readLocks.add(lckFile); } } return readLocks; } }
public class class_name { private Set<File> getReadLocks() { final Set<File> readLocks = new HashSet<File>(); File[] lckFiles = this.lockPath.listFiles(lockFilter); for (final File lckFile : lckFiles) { if (lockFilter.isReaderLockFile(lckFile)) { readLocks.add(lckFile); // depends on control dependency: [if], data = [none] } } return readLocks; } }
public class class_name { public static String getRegion(Locale locale) { String region = locale.getUnicodeLocaleType("rg"); if ((region != null) && (region.length() == 6)) { String upper = region.toUpperCase(Locale.US); if (upper.endsWith("ZZZZ")) { return upper.substring(0, 2); } } return locale.getCountry(); } }
public class class_name { public static String getRegion(Locale locale) { String region = locale.getUnicodeLocaleType("rg"); if ((region != null) && (region.length() == 6)) { String upper = region.toUpperCase(Locale.US); if (upper.endsWith("ZZZZ")) { return upper.substring(0, 2); // depends on control dependency: [if], data = [none] } } return locale.getCountry(); } }
public class class_name { private void initTrack(Benchmark... benchs) { if (!useTrack) return; String tpl = "<div id=%ID%horse class=horse><nobr><img class=himg src=images/bench/horse.gif><span>%ID%</span></nobr></div>"; GQuery g = $("#racefield").html(""); for (Benchmark b : benchs) { String id = b.getId(); String lg = id.contains("gwt") ? "gwt" : id; String s = tpl.replaceAll("%ID%", id).replaceAll("%LG%", lg); g.append($(s)); } GQuery flag = $("<img class=flag src='images/bench/animated-flag.gif'/>").appendTo(document); // These values are set in the css. int horseHeight = 35; int horseWidth = 150; int flagWidth = 35; int height = horseHeight * (benchs.length + 1); $("#racetrack").css("height", height + "px"); trackWidth = g.width() - horseWidth - flagWidth; flag.hide(); } }
public class class_name { private void initTrack(Benchmark... benchs) { if (!useTrack) return; String tpl = "<div id=%ID%horse class=horse><nobr><img class=himg src=images/bench/horse.gif><span>%ID%</span></nobr></div>"; GQuery g = $("#racefield").html(""); for (Benchmark b : benchs) { String id = b.getId(); String lg = id.contains("gwt") ? "gwt" : id; String s = tpl.replaceAll("%ID%", id).replaceAll("%LG%", lg); g.append($(s)); // depends on control dependency: [for], data = [none] } GQuery flag = $("<img class=flag src='images/bench/animated-flag.gif'/>").appendTo(document); // These values are set in the css. int horseHeight = 35; int horseWidth = 150; int flagWidth = 35; int height = horseHeight * (benchs.length + 1); $("#racetrack").css("height", height + "px"); trackWidth = g.width() - horseWidth - flagWidth; flag.hide(); } }
public class class_name { public String getFractionalSizeAsString() { if(_size == 0) return "0"; long sizeInBytes = getSizeInBytes(); // determine the biggest size unit with non 0 size for(SizeUnit sizeUnit : ORDERED_SIZE_UNIT) { if(sizeUnit == SizeUnit.BYTE) return String.valueOf(sizeInBytes); if(sizeInBytes >= sizeUnit.getBytesCount()) { double fractionalSize = (double) sizeInBytes / sizeUnit.getBytesCount(); return String.format("%.2f%s", fractionalSize, sizeUnit.getDisplayChar()); } } throw new RuntimeException("should not reach this line..."); } }
public class class_name { public String getFractionalSizeAsString() { if(_size == 0) return "0"; long sizeInBytes = getSizeInBytes(); // determine the biggest size unit with non 0 size for(SizeUnit sizeUnit : ORDERED_SIZE_UNIT) { if(sizeUnit == SizeUnit.BYTE) return String.valueOf(sizeInBytes); if(sizeInBytes >= sizeUnit.getBytesCount()) { double fractionalSize = (double) sizeInBytes / sizeUnit.getBytesCount(); return String.format("%.2f%s", fractionalSize, sizeUnit.getDisplayChar()); // depends on control dependency: [if], data = [none] } } throw new RuntimeException("should not reach this line..."); } }
public class class_name { public byte[] getBytes() { // avoid copy if `base` is `byte[]` if (offset == BYTE_ARRAY_OFFSET && base instanceof byte[] && ((byte[]) base).length == numBytes) { return (byte[]) base; } else { byte[] bytes = new byte[numBytes]; copyMemory(base, offset, bytes, BYTE_ARRAY_OFFSET, numBytes); return bytes; } } }
public class class_name { public byte[] getBytes() { // avoid copy if `base` is `byte[]` if (offset == BYTE_ARRAY_OFFSET && base instanceof byte[] && ((byte[]) base).length == numBytes) { return (byte[]) base; // depends on control dependency: [if], data = [none] } else { byte[] bytes = new byte[numBytes]; copyMemory(base, offset, bytes, BYTE_ARRAY_OFFSET, numBytes); // depends on control dependency: [if], data = [none] return bytes; // depends on control dependency: [if], data = [none] } } }
public class class_name { public void addListeners() { super.addListeners(); Record record = this.getMainRecord(); record.setKeyArea(DBConstants.MAIN_KEY_AREA); record.getCounterField().setString(this.getProperty(DBConstants.OBJECT_ID)); try { if (!record.seek(null)) return; // Never; ContactType recContactType = (ContactType)this.getRecord(ContactType.CONTACT_TYPE_FILE); recContactType = (ContactType)recContactType.getContactType(record); Record recMessageDetail = this.getRecord(MessageDetail.MESSAGE_DETAIL_FILE); recMessageDetail.setKeyArea(MessageDetail.CONTACT_TYPE_ID_KEY); recMessageDetail.addListener(new SubFileFilter(recContactType.getField(ContactType.ID), MessageDetail.CONTACT_TYPE_ID, (BaseField)record.getCounterField(), MessageDetail.PERSON_ID, null, null)); } catch (DBException e) { e.printStackTrace(); return; } MessageTransport recMessageTransport = (MessageTransport)this.getRecord(MessageTransport.MESSAGE_TRANSPORT_FILE); recMessageTransport = recMessageTransport.getMessageTransport(MessageTransport.SOAP); // For now - Only SOAP } }
public class class_name { public void addListeners() { super.addListeners(); Record record = this.getMainRecord(); record.setKeyArea(DBConstants.MAIN_KEY_AREA); record.getCounterField().setString(this.getProperty(DBConstants.OBJECT_ID)); try { if (!record.seek(null)) return; // Never; ContactType recContactType = (ContactType)this.getRecord(ContactType.CONTACT_TYPE_FILE); recContactType = (ContactType)recContactType.getContactType(record); // depends on control dependency: [try], data = [none] Record recMessageDetail = this.getRecord(MessageDetail.MESSAGE_DETAIL_FILE); recMessageDetail.setKeyArea(MessageDetail.CONTACT_TYPE_ID_KEY); // depends on control dependency: [try], data = [none] recMessageDetail.addListener(new SubFileFilter(recContactType.getField(ContactType.ID), MessageDetail.CONTACT_TYPE_ID, (BaseField)record.getCounterField(), MessageDetail.PERSON_ID, null, null)); // depends on control dependency: [try], data = [none] } catch (DBException e) { e.printStackTrace(); return; } // depends on control dependency: [catch], data = [none] MessageTransport recMessageTransport = (MessageTransport)this.getRecord(MessageTransport.MESSAGE_TRANSPORT_FILE); recMessageTransport = recMessageTransport.getMessageTransport(MessageTransport.SOAP); // For now - Only SOAP } }
public class class_name { public void buildContents(XMLNode node, Content contentTree) { Content contentListTree = writer.getContentsHeader(); PackageDoc[] packages = configuration.packages; printedPackageHeaders = new HashSet<String>(); for (int i = 0; i < packages.length; i++) { if (hasConstantField(packages[i]) && ! hasPrintedPackageIndex(packages[i].name())) { writer.addLinkToPackageContent(packages[i], parsePackageName(packages[i].name()), printedPackageHeaders, contentListTree); } } contentTree.addContent(writer.getContentsList(contentListTree)); } }
public class class_name { public void buildContents(XMLNode node, Content contentTree) { Content contentListTree = writer.getContentsHeader(); PackageDoc[] packages = configuration.packages; printedPackageHeaders = new HashSet<String>(); for (int i = 0; i < packages.length; i++) { if (hasConstantField(packages[i]) && ! hasPrintedPackageIndex(packages[i].name())) { writer.addLinkToPackageContent(packages[i], parsePackageName(packages[i].name()), printedPackageHeaders, contentListTree); // depends on control dependency: [if], data = [none] } } contentTree.addContent(writer.getContentsList(contentListTree)); } }
public class class_name { private static boolean isPartialRow(Iterable<ExpandedPair> pairs, Iterable<ExpandedRow> rows) { for (ExpandedRow r : rows) { boolean allFound = true; for (ExpandedPair p : pairs) { boolean found = false; for (ExpandedPair pp : r.getPairs()) { if (p.equals(pp)) { found = true; break; } } if (!found) { allFound = false; break; } } if (allFound) { // the row 'r' contain all the pairs from 'pairs' return true; } } return false; } }
public class class_name { private static boolean isPartialRow(Iterable<ExpandedPair> pairs, Iterable<ExpandedRow> rows) { for (ExpandedRow r : rows) { boolean allFound = true; for (ExpandedPair p : pairs) { boolean found = false; for (ExpandedPair pp : r.getPairs()) { if (p.equals(pp)) { found = true; // depends on control dependency: [if], data = [none] break; } } if (!found) { allFound = false; // depends on control dependency: [if], data = [none] break; } } if (allFound) { // the row 'r' contain all the pairs from 'pairs' return true; // depends on control dependency: [if], data = [none] } } return false; } }
public class class_name { private View compileView(String viewName, Map<String, Object> viewProps) { String language = (String) viewProps.get("language"); if (language == null) { language = "javascript"; } String mapSource = (String) viewProps.get("map"); if (mapSource == null) { return null; } Mapper mapBlock = View.getCompiler().compileMap(mapSource, language); if (mapBlock == null) { Log.w(TAG, "View %s has unknown map function: %s", viewName, mapSource); return null; } String reduceSource = (String) viewProps.get("reduce"); Reducer reduceBlock = null; if (reduceSource != null) { reduceBlock = View.getCompiler().compileReduce(reduceSource, language); if (reduceBlock == null) { Log.w(TAG, "View %s has unknown reduce function: %s", viewName, reduceBlock); return null; } } String version = Misc.HexSHA1Digest(viewProps.toString().getBytes()); View view = db.getView(viewName); view.setMapReduce(mapBlock, reduceBlock, version); String collation = (String) viewProps.get("collation"); if ("raw".equals(collation)) { view.setCollation(View.TDViewCollation.TDViewCollationRaw); } view.setDesignDoc(true); return view; } }
public class class_name { private View compileView(String viewName, Map<String, Object> viewProps) { String language = (String) viewProps.get("language"); if (language == null) { language = "javascript"; // depends on control dependency: [if], data = [none] } String mapSource = (String) viewProps.get("map"); if (mapSource == null) { return null; // depends on control dependency: [if], data = [none] } Mapper mapBlock = View.getCompiler().compileMap(mapSource, language); if (mapBlock == null) { Log.w(TAG, "View %s has unknown map function: %s", viewName, mapSource); // depends on control dependency: [if], data = [none] return null; // depends on control dependency: [if], data = [none] } String reduceSource = (String) viewProps.get("reduce"); Reducer reduceBlock = null; if (reduceSource != null) { reduceBlock = View.getCompiler().compileReduce(reduceSource, language); // depends on control dependency: [if], data = [(reduceSource] if (reduceBlock == null) { Log.w(TAG, "View %s has unknown reduce function: %s", viewName, reduceBlock); // depends on control dependency: [if], data = [none] return null; // depends on control dependency: [if], data = [none] } } String version = Misc.HexSHA1Digest(viewProps.toString().getBytes()); View view = db.getView(viewName); view.setMapReduce(mapBlock, reduceBlock, version); String collation = (String) viewProps.get("collation"); if ("raw".equals(collation)) { view.setCollation(View.TDViewCollation.TDViewCollationRaw); // depends on control dependency: [if], data = [none] } view.setDesignDoc(true); return view; } }
public class class_name { public void marshall(BrokerInstanceOption brokerInstanceOption, ProtocolMarshaller protocolMarshaller) { if (brokerInstanceOption == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(brokerInstanceOption.getAvailabilityZones(), AVAILABILITYZONES_BINDING); protocolMarshaller.marshall(brokerInstanceOption.getEngineType(), ENGINETYPE_BINDING); protocolMarshaller.marshall(brokerInstanceOption.getHostInstanceType(), HOSTINSTANCETYPE_BINDING); protocolMarshaller.marshall(brokerInstanceOption.getSupportedEngineVersions(), SUPPORTEDENGINEVERSIONS_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } } }
public class class_name { public void marshall(BrokerInstanceOption brokerInstanceOption, ProtocolMarshaller protocolMarshaller) { if (brokerInstanceOption == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(brokerInstanceOption.getAvailabilityZones(), AVAILABILITYZONES_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(brokerInstanceOption.getEngineType(), ENGINETYPE_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(brokerInstanceOption.getHostInstanceType(), HOSTINSTANCETYPE_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(brokerInstanceOption.getSupportedEngineVersions(), SUPPORTEDENGINEVERSIONS_BINDING); // depends on control dependency: [try], data = [none] } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public void marshall(CreateRelationalDatabaseRequest createRelationalDatabaseRequest, ProtocolMarshaller protocolMarshaller) { if (createRelationalDatabaseRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(createRelationalDatabaseRequest.getRelationalDatabaseName(), RELATIONALDATABASENAME_BINDING); protocolMarshaller.marshall(createRelationalDatabaseRequest.getAvailabilityZone(), AVAILABILITYZONE_BINDING); protocolMarshaller.marshall(createRelationalDatabaseRequest.getRelationalDatabaseBlueprintId(), RELATIONALDATABASEBLUEPRINTID_BINDING); protocolMarshaller.marshall(createRelationalDatabaseRequest.getRelationalDatabaseBundleId(), RELATIONALDATABASEBUNDLEID_BINDING); protocolMarshaller.marshall(createRelationalDatabaseRequest.getMasterDatabaseName(), MASTERDATABASENAME_BINDING); protocolMarshaller.marshall(createRelationalDatabaseRequest.getMasterUsername(), MASTERUSERNAME_BINDING); protocolMarshaller.marshall(createRelationalDatabaseRequest.getMasterUserPassword(), MASTERUSERPASSWORD_BINDING); protocolMarshaller.marshall(createRelationalDatabaseRequest.getPreferredBackupWindow(), PREFERREDBACKUPWINDOW_BINDING); protocolMarshaller.marshall(createRelationalDatabaseRequest.getPreferredMaintenanceWindow(), PREFERREDMAINTENANCEWINDOW_BINDING); protocolMarshaller.marshall(createRelationalDatabaseRequest.getPubliclyAccessible(), PUBLICLYACCESSIBLE_BINDING); protocolMarshaller.marshall(createRelationalDatabaseRequest.getTags(), TAGS_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } } }
public class class_name { public void marshall(CreateRelationalDatabaseRequest createRelationalDatabaseRequest, ProtocolMarshaller protocolMarshaller) { if (createRelationalDatabaseRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(createRelationalDatabaseRequest.getRelationalDatabaseName(), RELATIONALDATABASENAME_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(createRelationalDatabaseRequest.getAvailabilityZone(), AVAILABILITYZONE_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(createRelationalDatabaseRequest.getRelationalDatabaseBlueprintId(), RELATIONALDATABASEBLUEPRINTID_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(createRelationalDatabaseRequest.getRelationalDatabaseBundleId(), RELATIONALDATABASEBUNDLEID_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(createRelationalDatabaseRequest.getMasterDatabaseName(), MASTERDATABASENAME_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(createRelationalDatabaseRequest.getMasterUsername(), MASTERUSERNAME_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(createRelationalDatabaseRequest.getMasterUserPassword(), MASTERUSERPASSWORD_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(createRelationalDatabaseRequest.getPreferredBackupWindow(), PREFERREDBACKUPWINDOW_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(createRelationalDatabaseRequest.getPreferredMaintenanceWindow(), PREFERREDMAINTENANCEWINDOW_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(createRelationalDatabaseRequest.getPubliclyAccessible(), PUBLICLYACCESSIBLE_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(createRelationalDatabaseRequest.getTags(), TAGS_BINDING); // depends on control dependency: [try], data = [none] } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { protected LightblueClientConfiguration baseLightblueClientConfiguration() { String propertiesFilePath = context.getInitParameter(LIGHTBLUE_CLIENT_PROPERTIES_PATH_KEY); if (propertiesFilePath == null) { return PropertiesLightblueClientConfiguration.fromDefault(); } return PropertiesLightblueClientConfiguration.fromPath(Paths.get(propertiesFilePath)); } }
public class class_name { protected LightblueClientConfiguration baseLightblueClientConfiguration() { String propertiesFilePath = context.getInitParameter(LIGHTBLUE_CLIENT_PROPERTIES_PATH_KEY); if (propertiesFilePath == null) { return PropertiesLightblueClientConfiguration.fromDefault(); // depends on control dependency: [if], data = [none] } return PropertiesLightblueClientConfiguration.fromPath(Paths.get(propertiesFilePath)); } }
public class class_name { private String sqlProcess(String originSql, Map<String, Object> params) { if (params == null || params.size() == 0) return originSql; String newSql = originSql; for (Entry<String, Object> entry : params.entrySet()) { String paramName = entry.getKey(); Object paramObj = entry.getValue(); if (paramObj.getClass().isArray()) { String inSqlExp = inSqlProcess(paramName, paramObj); newSql = newSql.replaceAll("@" + paramName, inSqlExp); } if (paramObj instanceof Collection) { Collection<?> collection = (Collection<?>) paramObj; Object[] paramVals = Lang.collection2array(collection); String inSqlExp = inSqlProcess(paramName, paramVals); newSql = newSql.replaceAll("@" + paramName, inSqlExp); } } return newSql; } }
public class class_name { private String sqlProcess(String originSql, Map<String, Object> params) { if (params == null || params.size() == 0) return originSql; String newSql = originSql; for (Entry<String, Object> entry : params.entrySet()) { String paramName = entry.getKey(); Object paramObj = entry.getValue(); if (paramObj.getClass().isArray()) { String inSqlExp = inSqlProcess(paramName, paramObj); newSql = newSql.replaceAll("@" + paramName, inSqlExp); // depends on control dependency: [if], data = [none] } if (paramObj instanceof Collection) { Collection<?> collection = (Collection<?>) paramObj; Object[] paramVals = Lang.collection2array(collection); String inSqlExp = inSqlProcess(paramName, paramVals); newSql = newSql.replaceAll("@" + paramName, inSqlExp); // depends on control dependency: [if], data = [none] } } return newSql; } }
public class class_name { public final ReadFuture read() { if (!getConfig().isUseReadOperation()) { throw new IllegalStateException("useReadOperation is not enabled."); } Queue<ReadFuture> readyReadFutures = getReadyReadFutures(); ReadFuture future; synchronized (readyReadFutures) { future = readyReadFutures.poll(); if (future != null) { if (future.isClosed()) { // Let other readers get notified. readyReadFutures.offer(future); } } else { future = new DefaultReadFuture(this); getWaitingReadFutures().offer(future); } } return future; } }
public class class_name { public final ReadFuture read() { if (!getConfig().isUseReadOperation()) { throw new IllegalStateException("useReadOperation is not enabled."); } Queue<ReadFuture> readyReadFutures = getReadyReadFutures(); ReadFuture future; synchronized (readyReadFutures) { future = readyReadFutures.poll(); if (future != null) { if (future.isClosed()) { // Let other readers get notified. readyReadFutures.offer(future); // depends on control dependency: [if], data = [none] } } else { future = new DefaultReadFuture(this); // depends on control dependency: [if], data = [none] getWaitingReadFutures().offer(future); // depends on control dependency: [if], data = [(future] } } return future; } }
public class class_name { private void setUpSimpleRelation(Entity entity, ForeignKey fk) { Relation forwardRelation = buildSimpleRelation(entity, fk); entity.addRelation(forwardRelation); if (shouldCreateInverse(forwardRelation)) { Relation reverseRelation = forwardRelation.createInverse(); forwardRelation.getToEntity().addRelation(reverseRelation); } } }
public class class_name { private void setUpSimpleRelation(Entity entity, ForeignKey fk) { Relation forwardRelation = buildSimpleRelation(entity, fk); entity.addRelation(forwardRelation); if (shouldCreateInverse(forwardRelation)) { Relation reverseRelation = forwardRelation.createInverse(); forwardRelation.getToEntity().addRelation(reverseRelation); // depends on control dependency: [if], data = [none] } } }
public class class_name { public void startElement(String uri, String name, String qName, Attributes atts) { boolean isDebug = logger.isDebugEnabled(); m_CurrentString = null; try { switch (getLiteralId(qName)) { case MAPPING_REPOSITORY: { if (isDebug) logger.debug(" > " + tags.getTagById(MAPPING_REPOSITORY)); this.m_CurrentAttrContainer = m_repository; String defIso = atts.getValue(tags.getTagById(ISOLATION_LEVEL)); this.m_repository.setDefaultIsolationLevel(LockHelper.getIsolationLevelFor(defIso)); if (isDebug) logger.debug(" " + tags.getTagById(ISOLATION_LEVEL) + ": " + defIso); String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit); if (proxyPrefetchingLimit != null) { defProxyPrefetchingLimit = Integer.parseInt(proxyPrefetchingLimit); } // check repository version: String version = atts.getValue(tags.getTagById(REPOSITORY_VERSION)); if (DescriptorRepository.getVersion().equals(version)) { if (isDebug) logger.debug(" " + tags.getTagById(REPOSITORY_VERSION) + ": " + version); } else { throw new MetadataException("Repository version does not match. expected " + DescriptorRepository.getVersion() + " but found: " + version+". Please update your repository.dtd and your repository.xml"+ " version attribute entry"); } break; } case CLASS_DESCRIPTOR: { if (isDebug) logger.debug(" > " + tags.getTagById(CLASS_DESCRIPTOR)); m_CurrentCLD = new ClassDescriptor(m_repository); // prepare for custom attributes this.m_CurrentAttrContainer = this.m_CurrentCLD; // set isolation-level attribute String isoLevel = atts.getValue(tags.getTagById(ISOLATION_LEVEL)); if (isDebug) logger.debug(" " + tags.getTagById(ISOLATION_LEVEL) + ": " + isoLevel); /* arminw: only when an isolation-level is set in CLD, set it. Else the CLD use the default iso-level defined in the repository */ if(checkString(isoLevel)) m_CurrentCLD.setIsolationLevel(LockHelper.getIsolationLevelFor(isoLevel)); // set class attribute String classname = atts.getValue(tags.getTagById(CLASS_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(CLASS_NAME) + ": " + classname); try { m_CurrentCLD.setClassOfObject(ClassHelper.getClass(classname)); } catch (ClassNotFoundException e) { m_CurrentCLD = null; throw new MetadataException("Class "+classname+" could not be found" +" in the classpath. This could cause unexpected behaviour of OJB,"+ " please remove or comment out this class descriptor" + " in the repository.xml file.", e); } // set schema attribute String schema = atts.getValue(tags.getTagById(SCHEMA_NAME)); if (schema != null) { if (isDebug) logger.debug(" " + tags.getTagById(SCHEMA_NAME) + ": " + schema); m_CurrentCLD.setSchema(schema); } // set proxy attribute String proxy = atts.getValue(tags.getTagById(CLASS_PROXY)); if (isDebug) logger.debug(" " + tags.getTagById(CLASS_PROXY) + ": " + proxy); if (checkString(proxy)) { if (proxy.equalsIgnoreCase(ClassDescriptor.DYNAMIC_STR)) { m_CurrentCLD.setProxyClassName(ClassDescriptor.DYNAMIC_STR); } else { m_CurrentCLD.setProxyClassName(proxy); } } // set proxyPrefetchingLimit attribute String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit); if (proxyPrefetchingLimit == null) { m_CurrentCLD.setProxyPrefetchingLimit(defProxyPrefetchingLimit); } else { m_CurrentCLD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit)); } // set table attribute: String table = atts.getValue(tags.getTagById(TABLE_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(TABLE_NAME) + ": " + table); m_CurrentCLD.setTableName(table); if (table == null) { m_CurrentCLD.setIsInterface(true); } // set row-reader attribute String rowreader = atts.getValue(tags.getTagById(ROW_READER)); if (isDebug) logger.debug(" " + tags.getTagById(ROW_READER) + ": " + rowreader); if (rowreader != null) { m_CurrentCLD.setRowReader(rowreader); } // set if extends // arminw: TODO: this feature doesn't work, remove this stuff? String extendsAtt = atts.getValue(tags.getTagById(EXTENDS)); if (isDebug) logger.debug(" " + tags.getTagById(EXTENDS) + ": " + extendsAtt); if (checkString(extendsAtt)) { m_CurrentCLD.setSuperClass(extendsAtt); } //set accept-locks attribute String acceptLocks = atts.getValue(tags.getTagById(ACCEPT_LOCKS)); if (acceptLocks==null) acceptLocks="true"; // default is true logger.debug(" " + tags.getTagById(ACCEPT_LOCKS) + ": " + acceptLocks); if (isDebug) logger.debug(" " + tags.getTagById(ACCEPT_LOCKS) + ": " + acceptLocks); boolean b = (Boolean.valueOf(acceptLocks)).booleanValue(); m_CurrentCLD.setAcceptLocks(b); //set initializationMethod attribute String initializationMethod = atts.getValue(tags.getTagById(INITIALIZATION_METHOD)); if (isDebug) logger.debug(" " + tags.getTagById(INITIALIZATION_METHOD) + ": " + initializationMethod); if (initializationMethod != null) { m_CurrentCLD.setInitializationMethod(initializationMethod); } // set factoryClass attribute String factoryClass = atts.getValue(tags.getTagById(FACTORY_CLASS)); if (isDebug) logger.debug(" " + tags.getTagById(FACTORY_CLASS) + ": " + factoryClass); if (factoryClass != null) { m_CurrentCLD.setFactoryClass(factoryClass); } //set factoryMethod attribute String factoryMethod = atts.getValue(tags.getTagById(FACTORY_METHOD)); if (isDebug) logger.debug(" " + tags.getTagById(FACTORY_METHOD) + ": " + factoryMethod); if (factoryMethod != null) { m_CurrentCLD.setFactoryMethod(factoryMethod); } // set refresh attribute String refresh = atts.getValue(tags.getTagById(REFRESH)); if (isDebug) logger.debug(" " + tags.getTagById(REFRESH) + ": " + refresh); b = (Boolean.valueOf(refresh)).booleanValue(); m_CurrentCLD.setAlwaysRefresh(b); // TODO: remove this or make offical feature // persistent field String pfClassName = atts.getValue("persistent-field-class"); if (isDebug) logger.debug(" persistent-field-class: " + pfClassName); m_CurrentCLD.setPersistentFieldClassName(pfClassName); // put cld to the metadata repository m_repository.put(classname, m_CurrentCLD); break; } case OBJECT_CACHE: { // we only interessted in object-cache tags declared within // an class-descriptor if(m_CurrentCLD != null) { String className = atts.getValue(tags.getTagById(CLASS_NAME)); if(checkString(className)) { if (isDebug) logger.debug(" > " + tags.getTagById(OBJECT_CACHE)); ObjectCacheDescriptor ocd = new ObjectCacheDescriptor(); this.m_CurrentAttrContainer = ocd; ocd.setObjectCache(ClassHelper.getClass(className)); if(m_CurrentCLD != null) { m_CurrentCLD.setObjectCacheDescriptor(ocd); } if (isDebug) logger.debug(" " + tags.getTagById(CLASS_NAME) + ": " + className); } } break; } case CLASS_EXTENT: { String classname = atts.getValue("class-ref"); if (isDebug) logger.debug(" " + tags.getTagById(CLASS_EXTENT) + ": " + classname); m_CurrentCLD.addExtentClass(classname); break; } case FIELD_DESCRIPTOR: { if (isDebug) logger.debug(" > " + tags.getTagById(FIELD_DESCRIPTOR)); String strId = atts.getValue(tags.getTagById(ID)); m_lastId = (strId == null ? m_lastId + 1 : Integer.parseInt(strId)); String strAccess = atts.getValue(tags.getTagById(ACCESS)); if (RepositoryElements.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess)) { m_CurrentFLD = new AnonymousFieldDescriptor(m_CurrentCLD, m_lastId); } else { m_CurrentFLD = new FieldDescriptor(m_CurrentCLD, m_lastId); } m_CurrentFLD.setAccess(strAccess); m_CurrentCLD.addFieldDescriptor(m_CurrentFLD); // prepare for custom attributes this.m_CurrentAttrContainer = this.m_CurrentFLD; String fieldName = atts.getValue(tags.getTagById(FIELD_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + fieldName); if (RepositoryElements.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess)) { AnonymousFieldDescriptor anonymous = (AnonymousFieldDescriptor) m_CurrentFLD; anonymous.setPersistentField(null,fieldName); } else { String classname = m_CurrentCLD.getClassNameOfObject(); PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),ClassHelper.getClass(classname),fieldName); m_CurrentFLD.setPersistentField(pf); } String columnName = atts.getValue(tags.getTagById(COLUMN_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(COLUMN_NAME) + ": " + columnName); m_CurrentFLD.setColumnName(columnName); String jdbcType = atts.getValue(tags.getTagById(JDBC_TYPE)); if (isDebug) logger.debug(" " + tags.getTagById(JDBC_TYPE) + ": " + jdbcType); m_CurrentFLD.setColumnType(jdbcType); String primaryKey = atts.getValue(tags.getTagById(PRIMARY_KEY)); if (isDebug) logger.debug(" " + tags.getTagById(PRIMARY_KEY) + ": " + primaryKey); boolean b = (Boolean.valueOf(primaryKey)).booleanValue(); m_CurrentFLD.setPrimaryKey(b); String nullable = atts.getValue(tags.getTagById(NULLABLE)); if (nullable != null) { if (isDebug) logger.debug(" " + tags.getTagById(NULLABLE) + ": " + nullable); b = !(Boolean.valueOf(nullable)).booleanValue(); m_CurrentFLD.setRequired(b); } String indexed = atts.getValue(tags.getTagById(INDEXED)); if (isDebug) logger.debug(" " + tags.getTagById(INDEXED) + ": " + indexed); b = (Boolean.valueOf(indexed)).booleanValue(); m_CurrentFLD.setIndexed(b); String autoincrement = atts.getValue(tags.getTagById(AUTO_INCREMENT)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_INCREMENT) + ": " + autoincrement); b = (Boolean.valueOf(autoincrement)).booleanValue(); m_CurrentFLD.setAutoIncrement(b); String sequenceName = atts.getValue(tags.getTagById(SEQUENCE_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(SEQUENCE_NAME) + ": " + sequenceName); m_CurrentFLD.setSequenceName(sequenceName); String locking = atts.getValue(tags.getTagById(LOCKING)); if (isDebug) logger.debug(" " + tags.getTagById(LOCKING) + ": " + locking); b = (Boolean.valueOf(locking)).booleanValue(); m_CurrentFLD.setLocking(b); String updateLock = atts.getValue(tags.getTagById(UPDATE_LOCK)); if (isDebug) logger.debug(" " + tags.getTagById(UPDATE_LOCK) + ": " + updateLock); if(checkString(updateLock)) { b = (Boolean.valueOf(updateLock)).booleanValue(); m_CurrentFLD.setUpdateLock(b); } String fieldConversion = atts.getValue(tags.getTagById(FIELD_CONVERSION)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_CONVERSION) + ": " + fieldConversion); if (fieldConversion != null) { m_CurrentFLD.setFieldConversionClassName(fieldConversion); } // set length attribute String length = atts.getValue(tags.getTagById(LENGTH)); if (length != null) { int i = Integer.parseInt(length); if (isDebug) logger.debug(" " + tags.getTagById(LENGTH) + ": " + i); m_CurrentFLD.setLength(i); m_CurrentFLD.setLengthSpecified(true); } // set precision attribute String precision = atts.getValue(tags.getTagById(PRECISION)); if (precision != null) { int i = Integer.parseInt(precision); if (isDebug) logger.debug(" " + tags.getTagById(PRECISION) + ": " + i); m_CurrentFLD.setPrecision(i); m_CurrentFLD.setPrecisionSpecified(true); } // set scale attribute String scale = atts.getValue(tags.getTagById(SCALE)); if (scale != null) { int i = Integer.parseInt(scale); if (isDebug) logger.debug(" " + tags.getTagById(SCALE) + ": " + i); m_CurrentFLD.setScale(i); m_CurrentFLD.setScaleSpecified(true); } break; } case REFERENCE_DESCRIPTOR: { if (isDebug) logger.debug(" > " + tags.getTagById(REFERENCE_DESCRIPTOR)); // set name attribute name = atts.getValue(tags.getTagById(FIELD_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name); // set class-ref attribute String classRef = atts.getValue(tags.getTagById(REFERENCED_CLASS)); if (isDebug) logger.debug(" " + tags.getTagById(REFERENCED_CLASS) + ": " + classRef); ObjectReferenceDescriptor ord; if (name.equals(TAG_SUPER)) { // no longer needed sine SuperReferenceDescriptor was used // checkThis(classRef); // AnonymousObjectReferenceDescriptor aord = // new AnonymousObjectReferenceDescriptor(m_CurrentCLD); // aord.setPersistentField(null, TAG_SUPER); // ord = aord; ord = new SuperReferenceDescriptor(m_CurrentCLD); } else { ord = new ObjectReferenceDescriptor(m_CurrentCLD); PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),m_CurrentCLD.getClassOfObject(),name); ord.setPersistentField(pf); } m_CurrentORD = ord; // now we add the new descriptor m_CurrentCLD.addObjectReferenceDescriptor(m_CurrentORD); m_CurrentORD.setItemClass(ClassHelper.getClass(classRef)); // prepare for custom attributes this.m_CurrentAttrContainer = m_CurrentORD; // set proxy attribute String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy); boolean b = (Boolean.valueOf(proxy)).booleanValue(); m_CurrentORD.setLazy(b); // set proxyPrefetchingLimit attribute String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit); if (proxyPrefetchingLimit == null) { m_CurrentORD.setProxyPrefetchingLimit(defProxyPrefetchingLimit); } else { m_CurrentORD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit)); } // set refresh attribute String refresh = atts.getValue(tags.getTagById(REFRESH)); if (isDebug) logger.debug(" " + tags.getTagById(REFRESH) + ": " + refresh); b = (Boolean.valueOf(refresh)).booleanValue(); m_CurrentORD.setRefresh(b); // set auto-retrieve attribute String autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve); b = (Boolean.valueOf(autoRetrieve)).booleanValue(); m_CurrentORD.setCascadeRetrieve(b); // set auto-update attribute String autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate); if(autoUpdate != null) { m_CurrentORD.setCascadingStore(autoUpdate); } //set auto-delete attribute String autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete); if(autoDelete != null) { m_CurrentORD.setCascadingDelete(autoDelete); } //set otm-dependent attribute String otmDependent = atts.getValue(tags.getTagById(OTM_DEPENDENT)); if (isDebug) logger.debug(" " + tags.getTagById(OTM_DEPENDENT) + ": " + otmDependent); b = (Boolean.valueOf(otmDependent)).booleanValue(); m_CurrentORD.setOtmDependent(b); break; } case FOREIGN_KEY: { if (isDebug) logger.debug(" > " + tags.getTagById(FOREIGN_KEY)); String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF)); if (fieldIdRef != null) { if (isDebug) logger.debug(" " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef); try { int fieldId; fieldId = Integer.parseInt(fieldIdRef); m_CurrentORD.addForeignKeyField(fieldId); } catch (NumberFormatException rex) { throw new MetadataException(tags.getTagById(FIELD_ID_REF) + " attribute must be an int. Found: " + fieldIdRef + ". Please check your repository file.", rex); } } else { String fieldRef = atts.getValue(tags.getTagById(FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_REF) + ": " + fieldRef); m_CurrentORD.addForeignKeyField(fieldRef); } break; } case COLLECTION_DESCRIPTOR: { if (isDebug) logger.debug(" > " + tags.getTagById(COLLECTION_DESCRIPTOR)); m_CurrentCOD = new CollectionDescriptor(m_CurrentCLD); // prepare for custom attributes this.m_CurrentAttrContainer = m_CurrentCOD; // set name attribute name = atts.getValue(tags.getTagById(FIELD_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name); PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),m_CurrentCLD.getClassOfObject(),name); m_CurrentCOD.setPersistentField(pf); // set collection-class attribute String collectionClassName = atts.getValue(tags.getTagById(COLLECTION_CLASS)); if (collectionClassName != null) { if (isDebug) logger.debug(" " + tags.getTagById(COLLECTION_CLASS) + ": " + collectionClassName); m_CurrentCOD.setCollectionClass(ClassHelper.getClass(collectionClassName)); } // set element-class-ref attribute String elementClassRef = atts.getValue(tags.getTagById(ITEMS_CLASS)); if (isDebug) logger.debug(" " + tags.getTagById(ITEMS_CLASS) + ": " + elementClassRef); if (elementClassRef != null) { m_CurrentCOD.setItemClass(ClassHelper.getClass(elementClassRef)); } //set orderby and sort attributes: String orderby = atts.getValue(tags.getTagById(ORDERBY)); String sort = atts.getValue(tags.getTagById(SORT)); if (isDebug) logger.debug(" " + tags.getTagById(SORT) + ": " + orderby + ", " + sort); if (orderby != null) { m_CurrentCOD.addOrderBy(orderby, "ASC".equalsIgnoreCase(sort)); } // set indirection-table attribute String indirectionTable = atts.getValue(tags.getTagById(INDIRECTION_TABLE)); if (isDebug) logger.debug(" " + tags.getTagById(INDIRECTION_TABLE) + ": " + indirectionTable); m_CurrentCOD.setIndirectionTable(indirectionTable); // set proxy attribute String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy); boolean b = (Boolean.valueOf(proxy)).booleanValue(); m_CurrentCOD.setLazy(b); // set proxyPrefetchingLimit attribute String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit); if (proxyPrefetchingLimit == null) { m_CurrentCOD.setProxyPrefetchingLimit(defProxyPrefetchingLimit); } else { m_CurrentCOD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit)); } // set refresh attribute String refresh = atts.getValue(tags.getTagById(REFRESH)); if (isDebug) logger.debug(" " + tags.getTagById(REFRESH) + ": " + refresh); b = (Boolean.valueOf(refresh)).booleanValue(); m_CurrentCOD.setRefresh(b); // set auto-retrieve attribute String autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve); b = (Boolean.valueOf(autoRetrieve)).booleanValue(); m_CurrentCOD.setCascadeRetrieve(b); // set auto-update attribute String autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate); if(autoUpdate != null) { m_CurrentCOD.setCascadingStore(autoUpdate); } //set auto-delete attribute String autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete); if(autoDelete != null) { m_CurrentCOD.setCascadingDelete(autoDelete); } //set otm-dependent attribute String otmDependent = atts.getValue(tags.getTagById(OTM_DEPENDENT)); if (isDebug) logger.debug(" " + tags.getTagById(OTM_DEPENDENT) + ": " + otmDependent); b = (Boolean.valueOf(otmDependent)).booleanValue(); m_CurrentCOD.setOtmDependent(b); m_CurrentCLD.addCollectionDescriptor(m_CurrentCOD); break; } case ORDERBY : { if (isDebug) logger.debug(" > " + tags.getTagById(ORDERBY)); name = atts.getValue(tags.getTagById(FIELD_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name); String sort = atts.getValue(tags.getTagById(SORT)); if (isDebug) logger.debug(" " + tags.getTagById(SORT) + ": " + name + ", " + sort); m_CurrentCOD.addOrderBy(name, "ASC".equalsIgnoreCase(sort)); break; } case INVERSE_FK: { if (isDebug) logger.debug(" > " + tags.getTagById(INVERSE_FK)); String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF)); if (fieldIdRef != null) { if (isDebug) logger.debug(" " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef); try { int fieldId; fieldId = Integer.parseInt(fieldIdRef); m_CurrentCOD.addForeignKeyField(fieldId); } catch (NumberFormatException rex) { throw new MetadataException(tags.getTagById(FIELD_ID_REF) + " attribute must be an int. Found: " + fieldIdRef + " Please check your repository file.", rex); } } else { String fieldRef = atts.getValue(tags.getTagById(FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_REF) + ": " + fieldRef); m_CurrentCOD.addForeignKeyField(fieldRef); } break; } case FK_POINTING_TO_THIS_CLASS: { if (isDebug) logger.debug(" > " + tags.getTagById(FK_POINTING_TO_THIS_CLASS)); String column = atts.getValue("column"); if (isDebug) logger.debug(" " + "column" + ": " + column); m_CurrentCOD.addFkToThisClass(column); break; } case FK_POINTING_TO_ITEMS_CLASS: { if (isDebug) logger.debug(" > " + tags.getTagById(FK_POINTING_TO_ITEMS_CLASS)); String column = atts.getValue("column"); if (isDebug) logger.debug(" " + "column" + ": " + column); m_CurrentCOD.addFkToItemClass(column); break; } case ATTRIBUTE: { //handle custom attributes String attributeName = atts.getValue(tags.getTagById(ATTRIBUTE_NAME)); String attributeValue = atts.getValue(tags.getTagById(ATTRIBUTE_VALUE)); // If we have a container to store this attribute in, then do so. if (this.m_CurrentAttrContainer != null) { if (isDebug) logger.debug(" > " + tags.getTagById(ATTRIBUTE)); if (isDebug) logger.debug(" " + tags.getTagById(ATTRIBUTE_NAME) + ": " + attributeName); if (isDebug) logger.debug(" " + tags.getTagById(ATTRIBUTE_VALUE) + ": " + attributeValue); this.m_CurrentAttrContainer.addAttribute(attributeName, attributeValue); } else { // logger.debug("Found attribute (name="+attributeName+", value="+attributeValue+ // ") but I can not assign them to a descriptor"); } break; } // case SEQUENCE_MANAGER: // { // if (isDebug) logger.debug(" > " + tags.getTagById(SEQUENCE_MANAGER)); // // currently it's not possible to specify SM on class-descriptor level // // thus we use a dummy object to prevent ATTRIBUTE container report // // unassigned attributes // this.m_CurrentAttrContainer = new SequenceDescriptor(null); // break; // } case QUERY_CUSTOMIZER: { // set collection-class attribute String className = atts.getValue("class"); QueryCustomizer queryCust; if (className != null) { if (isDebug) logger.debug(" " + "class" + ": " + className); queryCust = (QueryCustomizer)ClassHelper.newInstance(className); m_CurrentAttrContainer = queryCust; m_CurrentCOD.setQueryCustomizer(queryCust); } break; } case INDEX_DESCRIPTOR: { m_CurrentIndexDescriptor = new IndexDescriptor(); m_CurrentIndexDescriptor.setName(atts.getValue(tags.getTagById(NAME))); m_CurrentIndexDescriptor.setUnique(Boolean.valueOf(atts.getValue(tags.getTagById(UNIQUE))).booleanValue()); break; } case INDEX_COLUMN: { m_CurrentIndexDescriptor.getIndexColumns().add(atts.getValue(tags.getTagById(NAME))); break; } case INSERT_PROCEDURE: { if (isDebug) logger.debug(" > " + tags.getTagById(INSERT_PROCEDURE)); // Get the proc name and the 'include all fields' setting String procName = atts.getValue(tags.getTagById(NAME)); String includeAllFields = atts.getValue(tags.getTagById(INCLUDE_ALL_FIELDS)); if (isDebug) logger.debug(" " + tags.getTagById(NAME) + ": " + procName); if (isDebug) logger.debug(" " + tags.getTagById(INCLUDE_ALL_FIELDS) + ": " + includeAllFields); // create the procedure descriptor InsertProcedureDescriptor proc = new InsertProcedureDescriptor(m_CurrentCLD, procName, Boolean.valueOf(includeAllFields).booleanValue()); m_CurrentProcedure = proc; // Get the name of the field ref that will receive the // return value. String returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(RETURN_FIELD_REF) + ": " + returnFieldRefName); proc.setReturnValueFieldRef(returnFieldRefName); break; } case UPDATE_PROCEDURE: { if (isDebug) logger.debug(" > " + tags.getTagById(UPDATE_PROCEDURE)); // Get the proc name and the 'include all fields' setting String procName = atts.getValue(tags.getTagById(NAME)); String includeAllFields = atts.getValue(tags.getTagById(INCLUDE_ALL_FIELDS)); if (isDebug) logger.debug(" " + tags.getTagById(NAME) + ": " + procName); if (isDebug) logger.debug(" " + tags.getTagById(INCLUDE_ALL_FIELDS) + ": " + includeAllFields); // create the procedure descriptor UpdateProcedureDescriptor proc = new UpdateProcedureDescriptor(m_CurrentCLD, procName, Boolean.valueOf(includeAllFields).booleanValue()); m_CurrentProcedure = proc; // Get the name of the field ref that will receive the // return value. String returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(RETURN_FIELD_REF) + ": " + returnFieldRefName); proc.setReturnValueFieldRef(returnFieldRefName); break; } case DELETE_PROCEDURE: { if (isDebug) logger.debug(" > " + tags.getTagById(DELETE_PROCEDURE)); // Get the proc name and the 'include all fields' setting String procName = atts.getValue(tags.getTagById(NAME)); String includeAllPkFields = atts.getValue(tags.getTagById(INCLUDE_PK_FIELDS_ONLY)); if (isDebug) logger.debug(" " + tags.getTagById(NAME) + ": " + procName); if (isDebug) logger.debug(" " + tags.getTagById(INCLUDE_PK_FIELDS_ONLY) + ": " + includeAllPkFields); // create the procedure descriptor DeleteProcedureDescriptor proc = new DeleteProcedureDescriptor(m_CurrentCLD, procName, Boolean.valueOf(includeAllPkFields).booleanValue()); m_CurrentProcedure = proc; // Get the name of the field ref that will receive the // return value. String returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(RETURN_FIELD_REF) + ": " + returnFieldRefName); proc.setReturnValueFieldRef(returnFieldRefName); break; } case CONSTANT_ARGUMENT: { if (isDebug) logger.debug(" > " + tags.getTagById(CONSTANT_ARGUMENT)); ArgumentDescriptor arg = new ArgumentDescriptor(m_CurrentProcedure); // Get the value String value = atts.getValue(tags.getTagById(VALUE)); if (isDebug) logger.debug(" " + tags.getTagById(VALUE) + ": " + value); // Set the value for the argument arg.setValue(value); // Add the argument to the procedure. m_CurrentProcedure.addArgument(arg); break; } case RUNTIME_ARGUMENT: { if (isDebug) logger.debug(" > " + tags.getTagById(RUNTIME_ARGUMENT)); ArgumentDescriptor arg = new ArgumentDescriptor(m_CurrentProcedure); // Get the name of the field ref String fieldRefName = atts.getValue(tags.getTagById(FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_REF) + ": " + fieldRefName); // Get the 'return' value. String returnValue = atts.getValue(tags.getTagById(RETURN)); if (isDebug) logger.debug(" " + tags.getTagById(RETURN) + ": " + returnValue); // Set the value for the argument. if ((fieldRefName != null) && (fieldRefName.trim().length() != 0)) { arg.setValue(fieldRefName, Boolean.valueOf(returnValue).booleanValue()); } // Add the argument to the procedure. m_CurrentProcedure.addArgument(arg); break; } default : { // nop } } } catch (Exception ex) { logger.error("Exception while read metadata", ex); if(ex instanceof MetadataException) throw (MetadataException)ex; else throw new MetadataException("Exception when reading metadata information,"+ " please check your repository.xml file", ex); } } }
public class class_name { public void startElement(String uri, String name, String qName, Attributes atts) { boolean isDebug = logger.isDebugEnabled(); m_CurrentString = null; try { switch (getLiteralId(qName)) { case MAPPING_REPOSITORY: { if (isDebug) logger.debug(" > " + tags.getTagById(MAPPING_REPOSITORY)); this.m_CurrentAttrContainer = m_repository; String defIso = atts.getValue(tags.getTagById(ISOLATION_LEVEL)); this.m_repository.setDefaultIsolationLevel(LockHelper.getIsolationLevelFor(defIso)); if (isDebug) logger.debug(" " + tags.getTagById(ISOLATION_LEVEL) + ": " + defIso); String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit); if (proxyPrefetchingLimit != null) { defProxyPrefetchingLimit = Integer.parseInt(proxyPrefetchingLimit); // depends on control dependency: [if], data = [(proxyPrefetchingLimit] } // check repository version: String version = atts.getValue(tags.getTagById(REPOSITORY_VERSION)); if (DescriptorRepository.getVersion().equals(version)) { if (isDebug) logger.debug(" " + tags.getTagById(REPOSITORY_VERSION) + ": " + version); } else { throw new MetadataException("Repository version does not match. expected " + DescriptorRepository.getVersion() + " but found: " + version+". Please update your repository.dtd and your repository.xml"+ " version attribute entry"); } break; } case CLASS_DESCRIPTOR: { if (isDebug) logger.debug(" > " + tags.getTagById(CLASS_DESCRIPTOR)); m_CurrentCLD = new ClassDescriptor(m_repository); // depends on control dependency: [try], data = [none] // prepare for custom attributes this.m_CurrentAttrContainer = this.m_CurrentCLD; // depends on control dependency: [try], data = [none] // set isolation-level attribute String isoLevel = atts.getValue(tags.getTagById(ISOLATION_LEVEL)); if (isDebug) logger.debug(" " + tags.getTagById(ISOLATION_LEVEL) + ": " + isoLevel); /* arminw: only when an isolation-level is set in CLD, set it. Else the CLD use the default iso-level defined in the repository */ if(checkString(isoLevel)) m_CurrentCLD.setIsolationLevel(LockHelper.getIsolationLevelFor(isoLevel)); // set class attribute String classname = atts.getValue(tags.getTagById(CLASS_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(CLASS_NAME) + ": " + classname); try { m_CurrentCLD.setClassOfObject(ClassHelper.getClass(classname)); // depends on control dependency: [try], data = [none] } catch (ClassNotFoundException e) { m_CurrentCLD = null; throw new MetadataException("Class "+classname+" could not be found" +" in the classpath. This could cause unexpected behaviour of OJB,"+ " please remove or comment out this class descriptor" + " in the repository.xml file.", e); } // depends on control dependency: [catch], data = [none] // set schema attribute String schema = atts.getValue(tags.getTagById(SCHEMA_NAME)); if (schema != null) { if (isDebug) logger.debug(" " + tags.getTagById(SCHEMA_NAME) + ": " + schema); m_CurrentCLD.setSchema(schema); // depends on control dependency: [if], data = [(schema] } // set proxy attribute String proxy = atts.getValue(tags.getTagById(CLASS_PROXY)); if (isDebug) logger.debug(" " + tags.getTagById(CLASS_PROXY) + ": " + proxy); if (checkString(proxy)) { if (proxy.equalsIgnoreCase(ClassDescriptor.DYNAMIC_STR)) { m_CurrentCLD.setProxyClassName(ClassDescriptor.DYNAMIC_STR); // depends on control dependency: [if], data = [none] } else { m_CurrentCLD.setProxyClassName(proxy); // depends on control dependency: [if], data = [none] } } // set proxyPrefetchingLimit attribute String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit); if (proxyPrefetchingLimit == null) { m_CurrentCLD.setProxyPrefetchingLimit(defProxyPrefetchingLimit); // depends on control dependency: [if], data = [none] } else { m_CurrentCLD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit)); // depends on control dependency: [if], data = [(proxyPrefetchingLimit] } // set table attribute: String table = atts.getValue(tags.getTagById(TABLE_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(TABLE_NAME) + ": " + table); m_CurrentCLD.setTableName(table); // depends on control dependency: [try], data = [none] if (table == null) { m_CurrentCLD.setIsInterface(true); // depends on control dependency: [if], data = [none] } // set row-reader attribute String rowreader = atts.getValue(tags.getTagById(ROW_READER)); if (isDebug) logger.debug(" " + tags.getTagById(ROW_READER) + ": " + rowreader); if (rowreader != null) { m_CurrentCLD.setRowReader(rowreader); // depends on control dependency: [if], data = [(rowreader] } // set if extends // arminw: TODO: this feature doesn't work, remove this stuff? String extendsAtt = atts.getValue(tags.getTagById(EXTENDS)); if (isDebug) logger.debug(" " + tags.getTagById(EXTENDS) + ": " + extendsAtt); if (checkString(extendsAtt)) { m_CurrentCLD.setSuperClass(extendsAtt); // depends on control dependency: [if], data = [none] } //set accept-locks attribute String acceptLocks = atts.getValue(tags.getTagById(ACCEPT_LOCKS)); if (acceptLocks==null) acceptLocks="true"; // default is true logger.debug(" " + tags.getTagById(ACCEPT_LOCKS) + ": " + acceptLocks); // depends on control dependency: [try], data = [none] if (isDebug) logger.debug(" " + tags.getTagById(ACCEPT_LOCKS) + ": " + acceptLocks); boolean b = (Boolean.valueOf(acceptLocks)).booleanValue(); m_CurrentCLD.setAcceptLocks(b); // depends on control dependency: [try], data = [none] //set initializationMethod attribute String initializationMethod = atts.getValue(tags.getTagById(INITIALIZATION_METHOD)); if (isDebug) logger.debug(" " + tags.getTagById(INITIALIZATION_METHOD) + ": " + initializationMethod); if (initializationMethod != null) { m_CurrentCLD.setInitializationMethod(initializationMethod); // depends on control dependency: [if], data = [(initializationMethod] } // set factoryClass attribute String factoryClass = atts.getValue(tags.getTagById(FACTORY_CLASS)); if (isDebug) logger.debug(" " + tags.getTagById(FACTORY_CLASS) + ": " + factoryClass); if (factoryClass != null) { m_CurrentCLD.setFactoryClass(factoryClass); // depends on control dependency: [if], data = [(factoryClass] } //set factoryMethod attribute String factoryMethod = atts.getValue(tags.getTagById(FACTORY_METHOD)); if (isDebug) logger.debug(" " + tags.getTagById(FACTORY_METHOD) + ": " + factoryMethod); if (factoryMethod != null) { m_CurrentCLD.setFactoryMethod(factoryMethod); // depends on control dependency: [if], data = [(factoryMethod] } // set refresh attribute String refresh = atts.getValue(tags.getTagById(REFRESH)); if (isDebug) logger.debug(" " + tags.getTagById(REFRESH) + ": " + refresh); b = (Boolean.valueOf(refresh)).booleanValue(); // depends on control dependency: [try], data = [none] m_CurrentCLD.setAlwaysRefresh(b); // depends on control dependency: [try], data = [none] // TODO: remove this or make offical feature // persistent field String pfClassName = atts.getValue("persistent-field-class"); if (isDebug) logger.debug(" persistent-field-class: " + pfClassName); m_CurrentCLD.setPersistentFieldClassName(pfClassName); // depends on control dependency: [try], data = [none] // put cld to the metadata repository m_repository.put(classname, m_CurrentCLD); // depends on control dependency: [try], data = [none] break; } case OBJECT_CACHE: { // we only interessted in object-cache tags declared within // an class-descriptor if(m_CurrentCLD != null) { String className = atts.getValue(tags.getTagById(CLASS_NAME)); if(checkString(className)) { if (isDebug) logger.debug(" > " + tags.getTagById(OBJECT_CACHE)); ObjectCacheDescriptor ocd = new ObjectCacheDescriptor(); this.m_CurrentAttrContainer = ocd; ocd.setObjectCache(ClassHelper.getClass(className)); if(m_CurrentCLD != null) { m_CurrentCLD.setObjectCacheDescriptor(ocd); } if (isDebug) logger.debug(" " + tags.getTagById(CLASS_NAME) + ": " + className); } } break; } case CLASS_EXTENT: { String classname = atts.getValue("class-ref"); if (isDebug) logger.debug(" " + tags.getTagById(CLASS_EXTENT) + ": " + classname); m_CurrentCLD.addExtentClass(classname); break; } case FIELD_DESCRIPTOR: { if (isDebug) logger.debug(" > " + tags.getTagById(FIELD_DESCRIPTOR)); String strId = atts.getValue(tags.getTagById(ID)); m_lastId = (strId == null ? m_lastId + 1 : Integer.parseInt(strId)); String strAccess = atts.getValue(tags.getTagById(ACCESS)); if (RepositoryElements.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess)) { m_CurrentFLD = new AnonymousFieldDescriptor(m_CurrentCLD, m_lastId); } else { m_CurrentFLD = new FieldDescriptor(m_CurrentCLD, m_lastId); } m_CurrentFLD.setAccess(strAccess); m_CurrentCLD.addFieldDescriptor(m_CurrentFLD); // prepare for custom attributes this.m_CurrentAttrContainer = this.m_CurrentFLD; String fieldName = atts.getValue(tags.getTagById(FIELD_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + fieldName); if (RepositoryElements.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess)) { AnonymousFieldDescriptor anonymous = (AnonymousFieldDescriptor) m_CurrentFLD; anonymous.setPersistentField(null,fieldName); } else { String classname = m_CurrentCLD.getClassNameOfObject(); PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),ClassHelper.getClass(classname),fieldName); m_CurrentFLD.setPersistentField(pf); } String columnName = atts.getValue(tags.getTagById(COLUMN_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(COLUMN_NAME) + ": " + columnName); m_CurrentFLD.setColumnName(columnName); String jdbcType = atts.getValue(tags.getTagById(JDBC_TYPE)); if (isDebug) logger.debug(" " + tags.getTagById(JDBC_TYPE) + ": " + jdbcType); m_CurrentFLD.setColumnType(jdbcType); String primaryKey = atts.getValue(tags.getTagById(PRIMARY_KEY)); if (isDebug) logger.debug(" " + tags.getTagById(PRIMARY_KEY) + ": " + primaryKey); boolean b = (Boolean.valueOf(primaryKey)).booleanValue(); m_CurrentFLD.setPrimaryKey(b); String nullable = atts.getValue(tags.getTagById(NULLABLE)); if (nullable != null) { if (isDebug) logger.debug(" " + tags.getTagById(NULLABLE) + ": " + nullable); b = !(Boolean.valueOf(nullable)).booleanValue(); m_CurrentFLD.setRequired(b); } String indexed = atts.getValue(tags.getTagById(INDEXED)); if (isDebug) logger.debug(" " + tags.getTagById(INDEXED) + ": " + indexed); b = (Boolean.valueOf(indexed)).booleanValue(); m_CurrentFLD.setIndexed(b); String autoincrement = atts.getValue(tags.getTagById(AUTO_INCREMENT)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_INCREMENT) + ": " + autoincrement); b = (Boolean.valueOf(autoincrement)).booleanValue(); m_CurrentFLD.setAutoIncrement(b); String sequenceName = atts.getValue(tags.getTagById(SEQUENCE_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(SEQUENCE_NAME) + ": " + sequenceName); m_CurrentFLD.setSequenceName(sequenceName); String locking = atts.getValue(tags.getTagById(LOCKING)); if (isDebug) logger.debug(" " + tags.getTagById(LOCKING) + ": " + locking); b = (Boolean.valueOf(locking)).booleanValue(); m_CurrentFLD.setLocking(b); String updateLock = atts.getValue(tags.getTagById(UPDATE_LOCK)); if (isDebug) logger.debug(" " + tags.getTagById(UPDATE_LOCK) + ": " + updateLock); if(checkString(updateLock)) { b = (Boolean.valueOf(updateLock)).booleanValue(); m_CurrentFLD.setUpdateLock(b); } String fieldConversion = atts.getValue(tags.getTagById(FIELD_CONVERSION)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_CONVERSION) + ": " + fieldConversion); if (fieldConversion != null) { m_CurrentFLD.setFieldConversionClassName(fieldConversion); } // set length attribute String length = atts.getValue(tags.getTagById(LENGTH)); if (length != null) { int i = Integer.parseInt(length); if (isDebug) logger.debug(" " + tags.getTagById(LENGTH) + ": " + i); m_CurrentFLD.setLength(i); m_CurrentFLD.setLengthSpecified(true); } // set precision attribute String precision = atts.getValue(tags.getTagById(PRECISION)); if (precision != null) { int i = Integer.parseInt(precision); if (isDebug) logger.debug(" " + tags.getTagById(PRECISION) + ": " + i); m_CurrentFLD.setPrecision(i); m_CurrentFLD.setPrecisionSpecified(true); } // set scale attribute String scale = atts.getValue(tags.getTagById(SCALE)); if (scale != null) { int i = Integer.parseInt(scale); if (isDebug) logger.debug(" " + tags.getTagById(SCALE) + ": " + i); m_CurrentFLD.setScale(i); m_CurrentFLD.setScaleSpecified(true); } break; } case REFERENCE_DESCRIPTOR: { if (isDebug) logger.debug(" > " + tags.getTagById(REFERENCE_DESCRIPTOR)); // set name attribute name = atts.getValue(tags.getTagById(FIELD_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name); // set class-ref attribute String classRef = atts.getValue(tags.getTagById(REFERENCED_CLASS)); if (isDebug) logger.debug(" " + tags.getTagById(REFERENCED_CLASS) + ": " + classRef); ObjectReferenceDescriptor ord; if (name.equals(TAG_SUPER)) { // no longer needed sine SuperReferenceDescriptor was used // checkThis(classRef); // AnonymousObjectReferenceDescriptor aord = // new AnonymousObjectReferenceDescriptor(m_CurrentCLD); // aord.setPersistentField(null, TAG_SUPER); // ord = aord; ord = new SuperReferenceDescriptor(m_CurrentCLD); } else { ord = new ObjectReferenceDescriptor(m_CurrentCLD); PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),m_CurrentCLD.getClassOfObject(),name); ord.setPersistentField(pf); } m_CurrentORD = ord; // now we add the new descriptor m_CurrentCLD.addObjectReferenceDescriptor(m_CurrentORD); m_CurrentORD.setItemClass(ClassHelper.getClass(classRef)); // prepare for custom attributes this.m_CurrentAttrContainer = m_CurrentORD; // set proxy attribute String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy); boolean b = (Boolean.valueOf(proxy)).booleanValue(); m_CurrentORD.setLazy(b); // set proxyPrefetchingLimit attribute String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit); if (proxyPrefetchingLimit == null) { m_CurrentORD.setProxyPrefetchingLimit(defProxyPrefetchingLimit); } else { m_CurrentORD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit)); } // set refresh attribute String refresh = atts.getValue(tags.getTagById(REFRESH)); if (isDebug) logger.debug(" " + tags.getTagById(REFRESH) + ": " + refresh); b = (Boolean.valueOf(refresh)).booleanValue(); m_CurrentORD.setRefresh(b); // set auto-retrieve attribute String autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve); b = (Boolean.valueOf(autoRetrieve)).booleanValue(); m_CurrentORD.setCascadeRetrieve(b); // set auto-update attribute String autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate); if(autoUpdate != null) { m_CurrentORD.setCascadingStore(autoUpdate); } //set auto-delete attribute String autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete); if(autoDelete != null) { m_CurrentORD.setCascadingDelete(autoDelete); } //set otm-dependent attribute String otmDependent = atts.getValue(tags.getTagById(OTM_DEPENDENT)); if (isDebug) logger.debug(" " + tags.getTagById(OTM_DEPENDENT) + ": " + otmDependent); b = (Boolean.valueOf(otmDependent)).booleanValue(); m_CurrentORD.setOtmDependent(b); break; } case FOREIGN_KEY: { if (isDebug) logger.debug(" > " + tags.getTagById(FOREIGN_KEY)); String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF)); if (fieldIdRef != null) { if (isDebug) logger.debug(" " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef); try { int fieldId; fieldId = Integer.parseInt(fieldIdRef); m_CurrentORD.addForeignKeyField(fieldId); } catch (NumberFormatException rex) { throw new MetadataException(tags.getTagById(FIELD_ID_REF) + " attribute must be an int. Found: " + fieldIdRef + ". Please check your repository file.", rex); } } else { String fieldRef = atts.getValue(tags.getTagById(FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_REF) + ": " + fieldRef); m_CurrentORD.addForeignKeyField(fieldRef); } break; } case COLLECTION_DESCRIPTOR: { if (isDebug) logger.debug(" > " + tags.getTagById(COLLECTION_DESCRIPTOR)); m_CurrentCOD = new CollectionDescriptor(m_CurrentCLD); // prepare for custom attributes this.m_CurrentAttrContainer = m_CurrentCOD; // set name attribute name = atts.getValue(tags.getTagById(FIELD_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name); PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),m_CurrentCLD.getClassOfObject(),name); m_CurrentCOD.setPersistentField(pf); // set collection-class attribute String collectionClassName = atts.getValue(tags.getTagById(COLLECTION_CLASS)); if (collectionClassName != null) { if (isDebug) logger.debug(" " + tags.getTagById(COLLECTION_CLASS) + ": " + collectionClassName); m_CurrentCOD.setCollectionClass(ClassHelper.getClass(collectionClassName)); } // set element-class-ref attribute String elementClassRef = atts.getValue(tags.getTagById(ITEMS_CLASS)); if (isDebug) logger.debug(" " + tags.getTagById(ITEMS_CLASS) + ": " + elementClassRef); if (elementClassRef != null) { m_CurrentCOD.setItemClass(ClassHelper.getClass(elementClassRef)); } //set orderby and sort attributes: String orderby = atts.getValue(tags.getTagById(ORDERBY)); String sort = atts.getValue(tags.getTagById(SORT)); if (isDebug) logger.debug(" " + tags.getTagById(SORT) + ": " + orderby + ", " + sort); if (orderby != null) { m_CurrentCOD.addOrderBy(orderby, "ASC".equalsIgnoreCase(sort)); } // set indirection-table attribute String indirectionTable = atts.getValue(tags.getTagById(INDIRECTION_TABLE)); if (isDebug) logger.debug(" " + tags.getTagById(INDIRECTION_TABLE) + ": " + indirectionTable); m_CurrentCOD.setIndirectionTable(indirectionTable); // set proxy attribute String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy); boolean b = (Boolean.valueOf(proxy)).booleanValue(); m_CurrentCOD.setLazy(b); // set proxyPrefetchingLimit attribute String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit); if (proxyPrefetchingLimit == null) { m_CurrentCOD.setProxyPrefetchingLimit(defProxyPrefetchingLimit); } else { m_CurrentCOD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit)); } // set refresh attribute String refresh = atts.getValue(tags.getTagById(REFRESH)); if (isDebug) logger.debug(" " + tags.getTagById(REFRESH) + ": " + refresh); b = (Boolean.valueOf(refresh)).booleanValue(); m_CurrentCOD.setRefresh(b); // set auto-retrieve attribute String autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve); b = (Boolean.valueOf(autoRetrieve)).booleanValue(); m_CurrentCOD.setCascadeRetrieve(b); // set auto-update attribute String autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate); if(autoUpdate != null) { m_CurrentCOD.setCascadingStore(autoUpdate); } //set auto-delete attribute String autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete); if(autoDelete != null) { m_CurrentCOD.setCascadingDelete(autoDelete); } //set otm-dependent attribute String otmDependent = atts.getValue(tags.getTagById(OTM_DEPENDENT)); if (isDebug) logger.debug(" " + tags.getTagById(OTM_DEPENDENT) + ": " + otmDependent); b = (Boolean.valueOf(otmDependent)).booleanValue(); m_CurrentCOD.setOtmDependent(b); m_CurrentCLD.addCollectionDescriptor(m_CurrentCOD); break; } case ORDERBY : { if (isDebug) logger.debug(" > " + tags.getTagById(ORDERBY)); name = atts.getValue(tags.getTagById(FIELD_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name); String sort = atts.getValue(tags.getTagById(SORT)); if (isDebug) logger.debug(" " + tags.getTagById(SORT) + ": " + name + ", " + sort); m_CurrentCOD.addOrderBy(name, "ASC".equalsIgnoreCase(sort)); break; } case INVERSE_FK: { if (isDebug) logger.debug(" > " + tags.getTagById(INVERSE_FK)); String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF)); if (fieldIdRef != null) { if (isDebug) logger.debug(" " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef); try { int fieldId; fieldId = Integer.parseInt(fieldIdRef); m_CurrentCOD.addForeignKeyField(fieldId); } catch (NumberFormatException rex) { throw new MetadataException(tags.getTagById(FIELD_ID_REF) + " attribute must be an int. Found: " + fieldIdRef + " Please check your repository file.", rex); } } else { String fieldRef = atts.getValue(tags.getTagById(FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_REF) + ": " + fieldRef); m_CurrentCOD.addForeignKeyField(fieldRef); } break; } case FK_POINTING_TO_THIS_CLASS: { if (isDebug) logger.debug(" > " + tags.getTagById(FK_POINTING_TO_THIS_CLASS)); String column = atts.getValue("column"); if (isDebug) logger.debug(" " + "column" + ": " + column); m_CurrentCOD.addFkToThisClass(column); break; } case FK_POINTING_TO_ITEMS_CLASS: { if (isDebug) logger.debug(" > " + tags.getTagById(FK_POINTING_TO_ITEMS_CLASS)); String column = atts.getValue("column"); if (isDebug) logger.debug(" " + "column" + ": " + column); m_CurrentCOD.addFkToItemClass(column); break; } case ATTRIBUTE: { //handle custom attributes String attributeName = atts.getValue(tags.getTagById(ATTRIBUTE_NAME)); String attributeValue = atts.getValue(tags.getTagById(ATTRIBUTE_VALUE)); // If we have a container to store this attribute in, then do so. if (this.m_CurrentAttrContainer != null) { if (isDebug) logger.debug(" > " + tags.getTagById(ATTRIBUTE)); if (isDebug) logger.debug(" " + tags.getTagById(ATTRIBUTE_NAME) + ": " + attributeName); if (isDebug) logger.debug(" " + tags.getTagById(ATTRIBUTE_VALUE) + ": " + attributeValue); this.m_CurrentAttrContainer.addAttribute(attributeName, attributeValue); } else { // logger.debug("Found attribute (name="+attributeName+", value="+attributeValue+ // ") but I can not assign them to a descriptor"); } break; } // case SEQUENCE_MANAGER: // { // if (isDebug) logger.debug(" > " + tags.getTagById(SEQUENCE_MANAGER)); // // currently it's not possible to specify SM on class-descriptor level // // thus we use a dummy object to prevent ATTRIBUTE container report // // unassigned attributes // this.m_CurrentAttrContainer = new SequenceDescriptor(null); // break; // } case QUERY_CUSTOMIZER: { // set collection-class attribute String className = atts.getValue("class"); QueryCustomizer queryCust; if (className != null) { if (isDebug) logger.debug(" " + "class" + ": " + className); queryCust = (QueryCustomizer)ClassHelper.newInstance(className); m_CurrentAttrContainer = queryCust; m_CurrentCOD.setQueryCustomizer(queryCust); } break; } case INDEX_DESCRIPTOR: { m_CurrentIndexDescriptor = new IndexDescriptor(); m_CurrentIndexDescriptor.setName(atts.getValue(tags.getTagById(NAME))); m_CurrentIndexDescriptor.setUnique(Boolean.valueOf(atts.getValue(tags.getTagById(UNIQUE))).booleanValue()); break; } case INDEX_COLUMN: { m_CurrentIndexDescriptor.getIndexColumns().add(atts.getValue(tags.getTagById(NAME))); break; } case INSERT_PROCEDURE: { if (isDebug) logger.debug(" > " + tags.getTagById(INSERT_PROCEDURE)); // Get the proc name and the 'include all fields' setting String procName = atts.getValue(tags.getTagById(NAME)); String includeAllFields = atts.getValue(tags.getTagById(INCLUDE_ALL_FIELDS)); if (isDebug) logger.debug(" " + tags.getTagById(NAME) + ": " + procName); if (isDebug) logger.debug(" " + tags.getTagById(INCLUDE_ALL_FIELDS) + ": " + includeAllFields); // create the procedure descriptor InsertProcedureDescriptor proc = new InsertProcedureDescriptor(m_CurrentCLD, procName, Boolean.valueOf(includeAllFields).booleanValue()); m_CurrentProcedure = proc; // Get the name of the field ref that will receive the // return value. String returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(RETURN_FIELD_REF) + ": " + returnFieldRefName); proc.setReturnValueFieldRef(returnFieldRefName); break; } case UPDATE_PROCEDURE: { if (isDebug) logger.debug(" > " + tags.getTagById(UPDATE_PROCEDURE)); // Get the proc name and the 'include all fields' setting String procName = atts.getValue(tags.getTagById(NAME)); String includeAllFields = atts.getValue(tags.getTagById(INCLUDE_ALL_FIELDS)); if (isDebug) logger.debug(" " + tags.getTagById(NAME) + ": " + procName); if (isDebug) logger.debug(" " + tags.getTagById(INCLUDE_ALL_FIELDS) + ": " + includeAllFields); // create the procedure descriptor UpdateProcedureDescriptor proc = new UpdateProcedureDescriptor(m_CurrentCLD, procName, Boolean.valueOf(includeAllFields).booleanValue()); m_CurrentProcedure = proc; // Get the name of the field ref that will receive the // return value. String returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(RETURN_FIELD_REF) + ": " + returnFieldRefName); proc.setReturnValueFieldRef(returnFieldRefName); break; } case DELETE_PROCEDURE: { if (isDebug) logger.debug(" > " + tags.getTagById(DELETE_PROCEDURE)); // Get the proc name and the 'include all fields' setting String procName = atts.getValue(tags.getTagById(NAME)); String includeAllPkFields = atts.getValue(tags.getTagById(INCLUDE_PK_FIELDS_ONLY)); if (isDebug) logger.debug(" " + tags.getTagById(NAME) + ": " + procName); if (isDebug) logger.debug(" " + tags.getTagById(INCLUDE_PK_FIELDS_ONLY) + ": " + includeAllPkFields); // create the procedure descriptor DeleteProcedureDescriptor proc = new DeleteProcedureDescriptor(m_CurrentCLD, procName, Boolean.valueOf(includeAllPkFields).booleanValue()); m_CurrentProcedure = proc; // Get the name of the field ref that will receive the // return value. String returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(RETURN_FIELD_REF) + ": " + returnFieldRefName); proc.setReturnValueFieldRef(returnFieldRefName); break; } case CONSTANT_ARGUMENT: { if (isDebug) logger.debug(" > " + tags.getTagById(CONSTANT_ARGUMENT)); ArgumentDescriptor arg = new ArgumentDescriptor(m_CurrentProcedure); // Get the value String value = atts.getValue(tags.getTagById(VALUE)); if (isDebug) logger.debug(" " + tags.getTagById(VALUE) + ": " + value); // Set the value for the argument arg.setValue(value); // Add the argument to the procedure. m_CurrentProcedure.addArgument(arg); break; } case RUNTIME_ARGUMENT: { if (isDebug) logger.debug(" > " + tags.getTagById(RUNTIME_ARGUMENT)); ArgumentDescriptor arg = new ArgumentDescriptor(m_CurrentProcedure); // Get the name of the field ref String fieldRefName = atts.getValue(tags.getTagById(FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_REF) + ": " + fieldRefName); // Get the 'return' value. String returnValue = atts.getValue(tags.getTagById(RETURN)); if (isDebug) logger.debug(" " + tags.getTagById(RETURN) + ": " + returnValue); // Set the value for the argument. if ((fieldRefName != null) && (fieldRefName.trim().length() != 0)) { arg.setValue(fieldRefName, Boolean.valueOf(returnValue).booleanValue()); } // Add the argument to the procedure. m_CurrentProcedure.addArgument(arg); break; } default : { // nop } } } catch (Exception ex) { logger.error("Exception while read metadata", ex); if(ex instanceof MetadataException) throw (MetadataException)ex; else throw new MetadataException("Exception when reading metadata information,"+ " please check your repository.xml file", ex); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public Space merge(Space other) { float minx = Math.min(x, other.x); float miny = Math.min(y, other.y); float newwidth = width+other.width; float newheight = height+other.height; if (x == other.x) { newwidth = width; } else { newheight = height; } return new Space(minx, miny, newwidth, newheight); } }
public class class_name { public Space merge(Space other) { float minx = Math.min(x, other.x); float miny = Math.min(y, other.y); float newwidth = width+other.width; float newheight = height+other.height; if (x == other.x) { newwidth = width; // depends on control dependency: [if], data = [none] } else { newheight = height; // depends on control dependency: [if], data = [none] } return new Space(minx, miny, newwidth, newheight); } }
public class class_name { private static Optional<String> findFirstManifestAttribute(File jarFile, String... attributes) throws IOException { if (attributes.length == 0) { return Optional.empty(); } try (JarFile f = new JarFile(jarFile)) { return findFirstManifestAttribute(f, attributes); } } }
public class class_name { private static Optional<String> findFirstManifestAttribute(File jarFile, String... attributes) throws IOException { if (attributes.length == 0) { return Optional.empty(); // depends on control dependency: [if], data = [none] } try (JarFile f = new JarFile(jarFile)) { return findFirstManifestAttribute(f, attributes); } } }
public class class_name { @Override @FFDCIgnore({ IOException.class }) public void run() { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){ Tr.debug(tc, "Run WriteListenerRunnable start, WriteListener enabled: " + this._listener +" , current thread -->"+ Thread.currentThread().getName()); } //clean up everything on this thread WebContainerRequestState reqState = WebContainerRequestState.getInstance(false); if (reqState!=null){ reqState.init(); } SRTServletRequestThreadData.getInstance().init(_requestDataWriteListenerThread); //Push the original thread's context onto the current thread, also save off the current thread's context _tcm.pushContextData(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){ Tr.debug(tc, "Invoking the onWritePossible first time"); } WebContainerRequestState.getInstance(true).setAttribute("com.ibm.ws.webcontainer.WriteAllowedonThisThread", true); if(_hout != null){ synchronized(_hout) { try { //call onWritePossible this._listener.onWritePossible(); } catch (Exception e){ if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){ Tr.debug(tc, "An exception occurred during the onWritePossible : " + e); } _hout.setExceptionDuringOnWP(true); _cb.error(_hout.getVc(), e ); } finally{ //Revert back to the thread's current context _tcm.popContextData(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){ Tr.debug(tc, "Run WriteListenerRunnable done"); } } } } else{ try { //call onWritePossible this._listener.onWritePossible(); } catch (IOException ioe){ if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){ Tr.debug(tc, "An exception occurred during the onWritePossible : " + ioe); } this._listener.onError(ioe); } finally{ //Revert back to the thread's current context _tcm.popContextData(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){ Tr.debug(tc, "Run WriteListenerRunnable done"); } } } } }
public class class_name { @Override @FFDCIgnore({ IOException.class }) public void run() { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){ Tr.debug(tc, "Run WriteListenerRunnable start, WriteListener enabled: " + this._listener +" , current thread -->"+ Thread.currentThread().getName()); // depends on control dependency: [if], data = [none] } //clean up everything on this thread WebContainerRequestState reqState = WebContainerRequestState.getInstance(false); if (reqState!=null){ reqState.init(); // depends on control dependency: [if], data = [none] } SRTServletRequestThreadData.getInstance().init(_requestDataWriteListenerThread); //Push the original thread's context onto the current thread, also save off the current thread's context _tcm.pushContextData(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){ Tr.debug(tc, "Invoking the onWritePossible first time"); // depends on control dependency: [if], data = [none] } WebContainerRequestState.getInstance(true).setAttribute("com.ibm.ws.webcontainer.WriteAllowedonThisThread", true); if(_hout != null){ synchronized(_hout) { // depends on control dependency: [if], data = [(_hout] try { //call onWritePossible this._listener.onWritePossible(); // depends on control dependency: [try], data = [none] } catch (Exception e){ if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){ Tr.debug(tc, "An exception occurred during the onWritePossible : " + e); // depends on control dependency: [if], data = [none] } _hout.setExceptionDuringOnWP(true); _cb.error(_hout.getVc(), e ); } // depends on control dependency: [catch], data = [none] finally{ //Revert back to the thread's current context _tcm.popContextData(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){ Tr.debug(tc, "Run WriteListenerRunnable done"); // depends on control dependency: [if], data = [none] } } } } else{ try { //call onWritePossible this._listener.onWritePossible(); // depends on control dependency: [try], data = [none] } catch (IOException ioe){ if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){ Tr.debug(tc, "An exception occurred during the onWritePossible : " + ioe); // depends on control dependency: [if], data = [none] } this._listener.onError(ioe); } // depends on control dependency: [catch], data = [none] finally{ //Revert back to the thread's current context _tcm.popContextData(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){ Tr.debug(tc, "Run WriteListenerRunnable done"); // depends on control dependency: [if], data = [none] } } } } }
public class class_name { private String fetchOfferings() { DiscovererFetchallResult allOfferings = null; try { String discovererOutput = discovererClient.getRequest("fetch_all", Collections.EMPTY_LIST); ObjectMapper mapper = new ObjectMapper(); allOfferings = mapper.readValue(discovererOutput, DiscovererFetchallResult.class); } catch (IOException e) { e.printStackTrace(); } String offerings = allOfferings.offering; return offerings; } }
public class class_name { private String fetchOfferings() { DiscovererFetchallResult allOfferings = null; try { String discovererOutput = discovererClient.getRequest("fetch_all", Collections.EMPTY_LIST); ObjectMapper mapper = new ObjectMapper(); allOfferings = mapper.readValue(discovererOutput, DiscovererFetchallResult.class); // depends on control dependency: [try], data = [none] } catch (IOException e) { e.printStackTrace(); } // depends on control dependency: [catch], data = [none] String offerings = allOfferings.offering; return offerings; } }
public class class_name { final KeyAwareLockPromise lockOrRegisterBackupLock(TxInvocationContext<?> ctx, Object key, long lockTimeout) throws InterruptedException { switch (cdl.getCacheTopology().getDistribution(key).writeOwnership()) { case PRIMARY: if (trace) { getLog().tracef("Acquiring locks on %s.", toStr(key)); } return checkPendingAndLockKey(ctx, key, lockTimeout); case BACKUP: if (trace) { getLog().tracef("Acquiring backup locks on %s.", key); } ctx.getCacheTransaction().addBackupLockForKey(key); default: return KeyAwareLockPromise.NO_OP; } } }
public class class_name { final KeyAwareLockPromise lockOrRegisterBackupLock(TxInvocationContext<?> ctx, Object key, long lockTimeout) throws InterruptedException { switch (cdl.getCacheTopology().getDistribution(key).writeOwnership()) { case PRIMARY: if (trace) { getLog().tracef("Acquiring locks on %s.", toStr(key)); // depends on control dependency: [if], data = [none] } return checkPendingAndLockKey(ctx, key, lockTimeout); case BACKUP: if (trace) { getLog().tracef("Acquiring backup locks on %s.", key); // depends on control dependency: [if], data = [none] } ctx.getCacheTransaction().addBackupLockForKey(key); default: return KeyAwareLockPromise.NO_OP; } } }
public class class_name { @Timed @Override public String get() { try { LOGGER.debug("mintPid()"); final HttpResponse resp = client.execute( minterRequest() ); return responseToPid( EntityUtils.toString(resp.getEntity()) ); } catch ( final IOException ex ) { LOGGER.warn("Error minting pid from {}: {}", url, ex.getMessage()); throw new PidMintingException("Error minting pid", ex); } catch ( final Exception ex ) { LOGGER.warn("Error processing minter response", ex.getMessage()); throw new PidMintingException("Error processing minter response", ex); } } }
public class class_name { @Timed @Override public String get() { try { LOGGER.debug("mintPid()"); // depends on control dependency: [try], data = [none] final HttpResponse resp = client.execute( minterRequest() ); return responseToPid( EntityUtils.toString(resp.getEntity()) ); // depends on control dependency: [try], data = [none] } catch ( final IOException ex ) { LOGGER.warn("Error minting pid from {}: {}", url, ex.getMessage()); throw new PidMintingException("Error minting pid", ex); } catch ( final Exception ex ) { // depends on control dependency: [catch], data = [none] LOGGER.warn("Error processing minter response", ex.getMessage()); throw new PidMintingException("Error processing minter response", ex); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public static Optional<AnnotationMirror> getAnnotationMirror(Element element, Class<? extends Annotation> annotationClass) { String annotationClassName = annotationClass.getCanonicalName(); for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) { TypeElement annotationTypeElement = asType(annotationMirror.getAnnotationType().asElement()); if (annotationTypeElement.getQualifiedName().contentEquals(annotationClassName)) { return Optional.of(annotationMirror); } } return Optional.absent(); } }
public class class_name { public static Optional<AnnotationMirror> getAnnotationMirror(Element element, Class<? extends Annotation> annotationClass) { String annotationClassName = annotationClass.getCanonicalName(); for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) { TypeElement annotationTypeElement = asType(annotationMirror.getAnnotationType().asElement()); if (annotationTypeElement.getQualifiedName().contentEquals(annotationClassName)) { return Optional.of(annotationMirror); // depends on control dependency: [if], data = [none] } } return Optional.absent(); } }
public class class_name { @Override public void remove(final String id, final Callback<Void> callback) { THREAD_POOL_EXECUTOR.execute(new Runnable() { Exception exception = null; @Override public void run() { try { RestAdapter.this.restRunner.onRemove(id); } catch (Exception e) { exception = e; } if (exception == null) { callback.onSuccess(null); } else { callback.onFailure(exception); } } }); } }
public class class_name { @Override public void remove(final String id, final Callback<Void> callback) { THREAD_POOL_EXECUTOR.execute(new Runnable() { Exception exception = null; @Override public void run() { try { RestAdapter.this.restRunner.onRemove(id); // depends on control dependency: [try], data = [none] } catch (Exception e) { exception = e; } // depends on control dependency: [catch], data = [none] if (exception == null) { callback.onSuccess(null); // depends on control dependency: [if], data = [null)] } else { callback.onFailure(exception); // depends on control dependency: [if], data = [(exception] } } }); } }
public class class_name { private void fillNode(final ResourceXMLParser.Entity entity, final NodeEntryImpl node) { node.setUsername(entity.getProperty(NODE_USERNAME)); node.setHostname(entity.getProperty(NODE_HOSTNAME)); node.setOsArch(entity.getProperty(NODE_OS_ARCH)); node.setOsFamily(entity.getProperty(NODE_OS_FAMILY)); node.setOsName(entity.getProperty(NODE_OS_NAME)); node.setOsVersion(entity.getProperty(NODE_OS_VERSION)); node.setDescription(entity.getProperty(COMMON_DESCRIPTION)); final String tags = entity.getProperty(COMMON_TAGS); final HashSet<String> tags1; if (null != tags && !"".equals(tags)) { tags1 = new HashSet<String>(); for (final String s : tags.split(",")) { tags1.add(s.trim()); } } else { tags1 = new HashSet<String>(); } node.setTags(tags1); if (null == node.getAttributes()) { node.setAttributes(new HashMap<String, String>()); } if (null != entity.getProperties()) { for (String key : entity.getProperties().stringPropertyNames()) { if (!ResourceXMLConstants.allPropSet.contains(key)) { node.getAttributes().put(key, entity.getProperty(key)); } } } //parse embedded attribute elements } }
public class class_name { private void fillNode(final ResourceXMLParser.Entity entity, final NodeEntryImpl node) { node.setUsername(entity.getProperty(NODE_USERNAME)); node.setHostname(entity.getProperty(NODE_HOSTNAME)); node.setOsArch(entity.getProperty(NODE_OS_ARCH)); node.setOsFamily(entity.getProperty(NODE_OS_FAMILY)); node.setOsName(entity.getProperty(NODE_OS_NAME)); node.setOsVersion(entity.getProperty(NODE_OS_VERSION)); node.setDescription(entity.getProperty(COMMON_DESCRIPTION)); final String tags = entity.getProperty(COMMON_TAGS); final HashSet<String> tags1; if (null != tags && !"".equals(tags)) { tags1 = new HashSet<String>(); // depends on control dependency: [if], data = [none] for (final String s : tags.split(",")) { tags1.add(s.trim()); // depends on control dependency: [for], data = [s] } } else { tags1 = new HashSet<String>(); // depends on control dependency: [if], data = [none] } node.setTags(tags1); if (null == node.getAttributes()) { node.setAttributes(new HashMap<String, String>()); // depends on control dependency: [if], data = [none] } if (null != entity.getProperties()) { for (String key : entity.getProperties().stringPropertyNames()) { if (!ResourceXMLConstants.allPropSet.contains(key)) { node.getAttributes().put(key, entity.getProperty(key)); // depends on control dependency: [if], data = [none] } } } //parse embedded attribute elements } }
public class class_name { public boolean queueAt(Alarm alarm, long wakeTime) { boolean isEarliest = false; long prevNextAlarmTime; do { prevNextAlarmTime = _nextAlarmTime.get(); } while (wakeTime > 0 && wakeTime < prevNextAlarmTime && ! _nextAlarmTime.compareAndSet(prevNextAlarmTime, wakeTime)); if (wakeTime < prevNextAlarmTime) { isEarliest = true; } long oldWakeTime = alarm.getAndSetWakeTime(wakeTime); if (oldWakeTime == wakeTime) { return false; } if (oldWakeTime > 0) { if (! dequeueImpl(alarm)) { /* System.out.println("FAIL: " + oldWakeTime + " " + wakeTime + " " + alarm); */ } } if (wakeTime <= 0) { return false; } long now = _now.get(); if (wakeTime <= now) { queueCurrent(alarm); return true; } synchronized (_lock) { if (alarm.getBucket() >= 0) { return false; } int bucket = getBucket(wakeTime); alarm.setBucket(bucket); Alarm top = _clockArray[bucket]; alarm.setNext(top); _clockArray[bucket] = alarm; } now = _now.get(); long nextWakeTime = alarm.getWakeTime(); if (nextWakeTime != wakeTime || wakeTime < now) { dequeueImpl(alarm); queueCurrent(alarm); } return isEarliest; } }
public class class_name { public boolean queueAt(Alarm alarm, long wakeTime) { boolean isEarliest = false; long prevNextAlarmTime; do { prevNextAlarmTime = _nextAlarmTime.get(); } while (wakeTime > 0 && wakeTime < prevNextAlarmTime && ! _nextAlarmTime.compareAndSet(prevNextAlarmTime, wakeTime)); if (wakeTime < prevNextAlarmTime) { isEarliest = true; // depends on control dependency: [if], data = [none] } long oldWakeTime = alarm.getAndSetWakeTime(wakeTime); if (oldWakeTime == wakeTime) { return false; // depends on control dependency: [if], data = [none] } if (oldWakeTime > 0) { if (! dequeueImpl(alarm)) { /* System.out.println("FAIL: " + oldWakeTime + " " + wakeTime + " " + alarm); */ } } if (wakeTime <= 0) { return false; // depends on control dependency: [if], data = [none] } long now = _now.get(); if (wakeTime <= now) { queueCurrent(alarm); // depends on control dependency: [if], data = [none] return true; // depends on control dependency: [if], data = [none] } synchronized (_lock) { if (alarm.getBucket() >= 0) { return false; // depends on control dependency: [if], data = [none] } int bucket = getBucket(wakeTime); alarm.setBucket(bucket); Alarm top = _clockArray[bucket]; alarm.setNext(top); _clockArray[bucket] = alarm; } now = _now.get(); long nextWakeTime = alarm.getWakeTime(); if (nextWakeTime != wakeTime || wakeTime < now) { dequeueImpl(alarm); // depends on control dependency: [if], data = [none] queueCurrent(alarm); // depends on control dependency: [if], data = [none] } return isEarliest; } }
public class class_name { public void parseRawValue(String value) { int valueIndex = 0; int elementIndex = 0; m_elements.clear(); while (valueIndex < value.length() && elementIndex < m_elements.size()) { int elementLength = m_lengths.get(elementIndex).intValue(); if (elementIndex > 0) { m_elements.add(m_separators.get(elementIndex - 1)); } int endIndex = valueIndex + elementLength; if (endIndex > value.length()) { endIndex = value.length(); } String element = value.substring(valueIndex, endIndex); m_elements.add(element); valueIndex += elementLength; elementIndex++; } } }
public class class_name { public void parseRawValue(String value) { int valueIndex = 0; int elementIndex = 0; m_elements.clear(); while (valueIndex < value.length() && elementIndex < m_elements.size()) { int elementLength = m_lengths.get(elementIndex).intValue(); if (elementIndex > 0) { m_elements.add(m_separators.get(elementIndex - 1)); // depends on control dependency: [if], data = [(elementIndex] } int endIndex = valueIndex + elementLength; if (endIndex > value.length()) { endIndex = value.length(); // depends on control dependency: [if], data = [none] } String element = value.substring(valueIndex, endIndex); m_elements.add(element); // depends on control dependency: [while], data = [none] valueIndex += elementLength; // depends on control dependency: [while], data = [none] elementIndex++; // depends on control dependency: [while], data = [none] } } }
public class class_name { public static BigDecimal inverse(final BigDecimal value) { if (isNotZero(value)) { return BigDecimal.ONE.setScale(MAX_SCALE_FOR_INVERSE).divide(value, BigDecimal.ROUND_HALF_UP); } return null; } }
public class class_name { public static BigDecimal inverse(final BigDecimal value) { if (isNotZero(value)) { return BigDecimal.ONE.setScale(MAX_SCALE_FOR_INVERSE).divide(value, BigDecimal.ROUND_HALF_UP); // depends on control dependency: [if], data = [none] } return null; } }
public class class_name { public static void normalizeL2( TupleDesc_F64 desc ) { double norm = 0; for (int i = 0; i < desc.size(); i++) { double v = desc.value[i]; norm += v*v; } if( norm == 0 ) return; norm = Math.sqrt(norm); for (int i = 0; i < desc.size(); i++) { desc.value[i] /= norm; } } }
public class class_name { public static void normalizeL2( TupleDesc_F64 desc ) { double norm = 0; for (int i = 0; i < desc.size(); i++) { double v = desc.value[i]; norm += v*v; // depends on control dependency: [for], data = [none] } if( norm == 0 ) return; norm = Math.sqrt(norm); for (int i = 0; i < desc.size(); i++) { desc.value[i] /= norm; // depends on control dependency: [for], data = [i] } } }
public class class_name { @Override protected List<Driver> createDrivers(TaskContext taskContext) { if (probeDriverFactory == null) { List<Type> ordersTypes = getColumnTypes("orders", "orderkey", "totalprice"); OperatorFactory ordersTableScan = createTableScanOperator(0, new PlanNodeId("test"), "orders", "orderkey", "totalprice"); JoinBridgeManager<PartitionedLookupSourceFactory> lookupSourceFactoryManager = JoinBridgeManager.lookupAllAtOnce(new PartitionedLookupSourceFactory( ordersTypes, ImmutableList.of(0, 1).stream() .map(ordersTypes::get) .collect(toImmutableList()), Ints.asList(0).stream() .map(ordersTypes::get) .collect(toImmutableList()), 1, requireNonNull(ImmutableMap.of(), "layout is null"), false)); HashBuilderOperatorFactory hashBuilder = new HashBuilderOperatorFactory( 1, new PlanNodeId("test"), lookupSourceFactoryManager, ImmutableList.of(0, 1), Ints.asList(0), OptionalInt.empty(), Optional.empty(), Optional.empty(), ImmutableList.of(), 1_500_000, new PagesIndex.TestingFactory(false), false, SingleStreamSpillerFactory.unsupportedSingleStreamSpillerFactory()); DriverContext driverContext = taskContext.addPipelineContext(0, false, false, false).addDriverContext(); DriverFactory buildDriverFactory = new DriverFactory(0, false, false, ImmutableList.of(ordersTableScan, hashBuilder), OptionalInt.empty(), UNGROUPED_EXECUTION); List<Type> lineItemTypes = getColumnTypes("lineitem", "orderkey", "quantity"); OperatorFactory lineItemTableScan = createTableScanOperator(0, new PlanNodeId("test"), "lineitem", "orderkey", "quantity"); OperatorFactory joinOperator = LOOKUP_JOIN_OPERATORS.innerJoin(1, new PlanNodeId("test"), lookupSourceFactoryManager, lineItemTypes, Ints.asList(0), OptionalInt.empty(), Optional.empty(), OptionalInt.empty(), unsupportedPartitioningSpillerFactory()); NullOutputOperatorFactory output = new NullOutputOperatorFactory(2, new PlanNodeId("test")); this.probeDriverFactory = new DriverFactory(1, true, true, ImmutableList.of(lineItemTableScan, joinOperator, output), OptionalInt.empty(), UNGROUPED_EXECUTION); Driver driver = buildDriverFactory.createDriver(driverContext); Future<LookupSourceProvider> lookupSourceProvider = lookupSourceFactoryManager.getJoinBridge(Lifespan.taskWide()).createLookupSourceProvider(); while (!lookupSourceProvider.isDone()) { driver.process(); } getFutureValue(lookupSourceProvider).close(); } DriverContext driverContext = taskContext.addPipelineContext(1, true, true, false).addDriverContext(); Driver driver = probeDriverFactory.createDriver(driverContext); return ImmutableList.of(driver); } }
public class class_name { @Override protected List<Driver> createDrivers(TaskContext taskContext) { if (probeDriverFactory == null) { List<Type> ordersTypes = getColumnTypes("orders", "orderkey", "totalprice"); OperatorFactory ordersTableScan = createTableScanOperator(0, new PlanNodeId("test"), "orders", "orderkey", "totalprice"); JoinBridgeManager<PartitionedLookupSourceFactory> lookupSourceFactoryManager = JoinBridgeManager.lookupAllAtOnce(new PartitionedLookupSourceFactory( ordersTypes, ImmutableList.of(0, 1).stream() .map(ordersTypes::get) .collect(toImmutableList()), Ints.asList(0).stream() .map(ordersTypes::get) .collect(toImmutableList()), 1, requireNonNull(ImmutableMap.of(), "layout is null"), false)); HashBuilderOperatorFactory hashBuilder = new HashBuilderOperatorFactory( 1, new PlanNodeId("test"), lookupSourceFactoryManager, ImmutableList.of(0, 1), Ints.asList(0), OptionalInt.empty(), Optional.empty(), Optional.empty(), ImmutableList.of(), 1_500_000, new PagesIndex.TestingFactory(false), false, SingleStreamSpillerFactory.unsupportedSingleStreamSpillerFactory()); DriverContext driverContext = taskContext.addPipelineContext(0, false, false, false).addDriverContext(); DriverFactory buildDriverFactory = new DriverFactory(0, false, false, ImmutableList.of(ordersTableScan, hashBuilder), OptionalInt.empty(), UNGROUPED_EXECUTION); List<Type> lineItemTypes = getColumnTypes("lineitem", "orderkey", "quantity"); OperatorFactory lineItemTableScan = createTableScanOperator(0, new PlanNodeId("test"), "lineitem", "orderkey", "quantity"); OperatorFactory joinOperator = LOOKUP_JOIN_OPERATORS.innerJoin(1, new PlanNodeId("test"), lookupSourceFactoryManager, lineItemTypes, Ints.asList(0), OptionalInt.empty(), Optional.empty(), OptionalInt.empty(), unsupportedPartitioningSpillerFactory()); NullOutputOperatorFactory output = new NullOutputOperatorFactory(2, new PlanNodeId("test")); this.probeDriverFactory = new DriverFactory(1, true, true, ImmutableList.of(lineItemTableScan, joinOperator, output), OptionalInt.empty(), UNGROUPED_EXECUTION); // depends on control dependency: [if], data = [none] Driver driver = buildDriverFactory.createDriver(driverContext); Future<LookupSourceProvider> lookupSourceProvider = lookupSourceFactoryManager.getJoinBridge(Lifespan.taskWide()).createLookupSourceProvider(); while (!lookupSourceProvider.isDone()) { driver.process(); // depends on control dependency: [while], data = [none] } getFutureValue(lookupSourceProvider).close(); // depends on control dependency: [if], data = [none] } DriverContext driverContext = taskContext.addPipelineContext(1, true, true, false).addDriverContext(); Driver driver = probeDriverFactory.createDriver(driverContext); return ImmutableList.of(driver); } }
public class class_name { public void startElement(String uri, String lname, String name, Attributes attrs) { // System.err.println("Start: " + name); // super.handleStartingTags is replaced with handleStartingTags // suggestion by Vu Ngoc Tan/Hop name = name.toLowerCase(); if (HtmlTagMap.isHtml(name)) { // we do nothing return; } if (HtmlTagMap.isHead(name)) { // we do nothing return; } if (HtmlTagMap.isTitle(name)) { // we do nothing return; } if (HtmlTagMap.isMeta(name)) { // we look if we can change the body attributes String meta = null; String content = null; if (attrs != null) { for (int i = 0; i < attrs.getLength(); i++) { String attribute = attrs.getQName(i); if (attribute.equalsIgnoreCase(HtmlTags.CONTENT)) content = attrs.getValue(i); else if (attribute.equalsIgnoreCase(HtmlTags.NAME)) meta = attrs.getValue(i); } } if (meta != null && content != null) { bodyAttributes.put(meta, content); } return; } if (HtmlTagMap.isLink(name)) { // we do nothing for the moment, in a later version we could extract // the style sheet return; } if (HtmlTagMap.isBody(name)) { // maybe we could extract some info about the document: color, // margins,... // but that's for a later version... XmlPeer peer = new XmlPeer(ElementTags.ITEXT, name); peer.addAlias(ElementTags.TOP, HtmlTags.TOPMARGIN); peer.addAlias(ElementTags.BOTTOM, HtmlTags.BOTTOMMARGIN); peer.addAlias(ElementTags.RIGHT, HtmlTags.RIGHTMARGIN); peer.addAlias(ElementTags.LEFT, HtmlTags.LEFTMARGIN); bodyAttributes.putAll(peer.getAttributes(attrs)); handleStartingTags(peer.getTag(), bodyAttributes); return; } if (myTags.containsKey(name)) { XmlPeer peer = (XmlPeer) myTags.get(name); if (ElementTags.TABLE.equals(peer.getTag()) || ElementTags.CELL.equals(peer.getTag())) { Properties p = peer.getAttributes(attrs); String value; if (ElementTags.TABLE.equals(peer.getTag()) && (value = p.getProperty(ElementTags.BORDERWIDTH)) != null) { if (Float.parseFloat(value + "f") > 0) { tableBorder = true; } } if (tableBorder) { p.put(ElementTags.LEFT, String.valueOf(true)); p.put(ElementTags.RIGHT, String.valueOf(true)); p.put(ElementTags.TOP, String.valueOf(true)); p.put(ElementTags.BOTTOM, String.valueOf(true)); } handleStartingTags(peer.getTag(), p); return; } handleStartingTags(peer.getTag(), peer.getAttributes(attrs)); return; } Properties attributes = new Properties(); if (attrs != null) { for (int i = 0; i < attrs.getLength(); i++) { String attribute = attrs.getQName(i).toLowerCase(); attributes.setProperty(attribute, attrs.getValue(i).toLowerCase()); } } handleStartingTags(name, attributes); } }
public class class_name { public void startElement(String uri, String lname, String name, Attributes attrs) { // System.err.println("Start: " + name); // super.handleStartingTags is replaced with handleStartingTags // suggestion by Vu Ngoc Tan/Hop name = name.toLowerCase(); if (HtmlTagMap.isHtml(name)) { // we do nothing return; // depends on control dependency: [if], data = [none] } if (HtmlTagMap.isHead(name)) { // we do nothing return; // depends on control dependency: [if], data = [none] } if (HtmlTagMap.isTitle(name)) { // we do nothing return; // depends on control dependency: [if], data = [none] } if (HtmlTagMap.isMeta(name)) { // we look if we can change the body attributes String meta = null; String content = null; if (attrs != null) { for (int i = 0; i < attrs.getLength(); i++) { String attribute = attrs.getQName(i); if (attribute.equalsIgnoreCase(HtmlTags.CONTENT)) content = attrs.getValue(i); else if (attribute.equalsIgnoreCase(HtmlTags.NAME)) meta = attrs.getValue(i); } } if (meta != null && content != null) { bodyAttributes.put(meta, content); // depends on control dependency: [if], data = [(meta] } return; // depends on control dependency: [if], data = [none] } if (HtmlTagMap.isLink(name)) { // we do nothing for the moment, in a later version we could extract // the style sheet return; // depends on control dependency: [if], data = [none] } if (HtmlTagMap.isBody(name)) { // maybe we could extract some info about the document: color, // margins,... // but that's for a later version... XmlPeer peer = new XmlPeer(ElementTags.ITEXT, name); peer.addAlias(ElementTags.TOP, HtmlTags.TOPMARGIN); // depends on control dependency: [if], data = [none] peer.addAlias(ElementTags.BOTTOM, HtmlTags.BOTTOMMARGIN); // depends on control dependency: [if], data = [none] peer.addAlias(ElementTags.RIGHT, HtmlTags.RIGHTMARGIN); // depends on control dependency: [if], data = [none] peer.addAlias(ElementTags.LEFT, HtmlTags.LEFTMARGIN); // depends on control dependency: [if], data = [none] bodyAttributes.putAll(peer.getAttributes(attrs)); // depends on control dependency: [if], data = [none] handleStartingTags(peer.getTag(), bodyAttributes); // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } if (myTags.containsKey(name)) { XmlPeer peer = (XmlPeer) myTags.get(name); if (ElementTags.TABLE.equals(peer.getTag()) || ElementTags.CELL.equals(peer.getTag())) { Properties p = peer.getAttributes(attrs); String value; if (ElementTags.TABLE.equals(peer.getTag()) && (value = p.getProperty(ElementTags.BORDERWIDTH)) != null) { if (Float.parseFloat(value + "f") > 0) { tableBorder = true; // depends on control dependency: [if], data = [none] } } if (tableBorder) { p.put(ElementTags.LEFT, String.valueOf(true)); // depends on control dependency: [if], data = [none] p.put(ElementTags.RIGHT, String.valueOf(true)); // depends on control dependency: [if], data = [none] p.put(ElementTags.TOP, String.valueOf(true)); // depends on control dependency: [if], data = [none] p.put(ElementTags.BOTTOM, String.valueOf(true)); // depends on control dependency: [if], data = [none] } handleStartingTags(peer.getTag(), p); // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } handleStartingTags(peer.getTag(), peer.getAttributes(attrs)); // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } Properties attributes = new Properties(); if (attrs != null) { for (int i = 0; i < attrs.getLength(); i++) { String attribute = attrs.getQName(i).toLowerCase(); attributes.setProperty(attribute, attrs.getValue(i).toLowerCase()); // depends on control dependency: [for], data = [i] } } handleStartingTags(name, attributes); } }
public class class_name { public void marshall(Condition condition, ProtocolMarshaller protocolMarshaller) { if (condition == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(condition.getConditionType(), CONDITIONTYPE_BINDING); protocolMarshaller.marshall(condition.getConditionKey(), CONDITIONKEY_BINDING); protocolMarshaller.marshall(condition.getConditionValue(), CONDITIONVALUE_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } } }
public class class_name { public void marshall(Condition condition, ProtocolMarshaller protocolMarshaller) { if (condition == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(condition.getConditionType(), CONDITIONTYPE_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(condition.getConditionKey(), CONDITIONKEY_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(condition.getConditionValue(), CONDITIONVALUE_BINDING); // depends on control dependency: [try], data = [none] } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public int doRecordChange(FieldInfo field, int iChangeType, boolean bDisplayOption) { // Read a valid record int iErrorCode = DBConstants.NORMAL_RETURN; switch (iChangeType) { case DBConstants.DELETE_TYPE: m_recDependent = this.getSubRecord(); if (m_recDependent != null) { try { if (!m_bRemoveSubRecords) { m_recDependent.close(); if (m_recDependent.hasNext()) { // Error - Can't delete the main record if there are sub-records. org.jbundle.model.Task task = null; if (this.getOwner() != null) if (this.getOwner().getRecordOwner() != null) task = this.getOwner().getRecordOwner().getTask(); String strError = "Sub-File Not Empty"; if (task != null) { strError = ((BaseApplication)task.getApplication()).getResources(ResourceConstants.ERROR_RESOURCE, true).getString(strError); return task.setLastError(strError); } return DBConstants.ERROR_RETURN; } } else { m_recDependent.close(); while (m_recDependent.hasNext()) { m_recDependent.next(); m_recDependent.edit(); m_recDependent.remove(); } } } catch (DBException ex) { ex.printStackTrace(); } } break; } if (iErrorCode != DBConstants.NORMAL_RETURN) return iErrorCode; return super.doRecordChange(field, iChangeType, bDisplayOption); // Initialize the record } }
public class class_name { public int doRecordChange(FieldInfo field, int iChangeType, boolean bDisplayOption) { // Read a valid record int iErrorCode = DBConstants.NORMAL_RETURN; switch (iChangeType) { case DBConstants.DELETE_TYPE: m_recDependent = this.getSubRecord(); if (m_recDependent != null) { try { if (!m_bRemoveSubRecords) { m_recDependent.close(); // depends on control dependency: [if], data = [none] if (m_recDependent.hasNext()) { // Error - Can't delete the main record if there are sub-records. org.jbundle.model.Task task = null; if (this.getOwner() != null) if (this.getOwner().getRecordOwner() != null) task = this.getOwner().getRecordOwner().getTask(); String strError = "Sub-File Not Empty"; if (task != null) { strError = ((BaseApplication)task.getApplication()).getResources(ResourceConstants.ERROR_RESOURCE, true).getString(strError); // depends on control dependency: [if], data = [none] return task.setLastError(strError); // depends on control dependency: [if], data = [none] } return DBConstants.ERROR_RETURN; // depends on control dependency: [if], data = [none] } } else { m_recDependent.close(); // depends on control dependency: [if], data = [none] while (m_recDependent.hasNext()) { m_recDependent.next(); // depends on control dependency: [while], data = [none] m_recDependent.edit(); // depends on control dependency: [while], data = [none] m_recDependent.remove(); // depends on control dependency: [while], data = [none] } } } catch (DBException ex) { ex.printStackTrace(); } // depends on control dependency: [catch], data = [none] } break; } if (iErrorCode != DBConstants.NORMAL_RETURN) return iErrorCode; return super.doRecordChange(field, iChangeType, bDisplayOption); // Initialize the record } }
public class class_name { public static String camelCaseToSnakeCase(String camelCase) { if (null == camelCase || camelCase.length()==0) return camelCase; StringBuilder snakeCase = new StringBuilder(camelCase.length()+3); snakeCase.append(camelCase.charAt(0)); boolean hasCamelCase=false; for (int i = 1; i < camelCase.length(); i++) { char c = camelCase.charAt(i); if (Character.isUpperCase(c)) { snakeCase.append("-"); c = Character.toLowerCase(c); hasCamelCase=true; } snakeCase.append(c); } if (!hasCamelCase) return camelCase; return snakeCase.toString(); } }
public class class_name { public static String camelCaseToSnakeCase(String camelCase) { if (null == camelCase || camelCase.length()==0) return camelCase; StringBuilder snakeCase = new StringBuilder(camelCase.length()+3); snakeCase.append(camelCase.charAt(0)); boolean hasCamelCase=false; for (int i = 1; i < camelCase.length(); i++) { char c = camelCase.charAt(i); if (Character.isUpperCase(c)) { snakeCase.append("-"); // depends on control dependency: [if], data = [none] c = Character.toLowerCase(c); // depends on control dependency: [if], data = [none] hasCamelCase=true; // depends on control dependency: [if], data = [none] } snakeCase.append(c); // depends on control dependency: [for], data = [none] } if (!hasCamelCase) return camelCase; return snakeCase.toString(); } }
public class class_name { public static <T> CellValidator cellValidator(T obj) { if (obj == null) { return null; } Kind kind = Kind.objectToKind(obj); AbstractType<?> tAbstractType = CassandraUtils.marshallerInstance(obj); String validatorClassName = tAbstractType.getClass().getCanonicalName(); Collection<String> validatorTypes = null; DataType.Name cqlTypeName = MAP_JAVA_TYPE_TO_DATA_TYPE_NAME.get(validatorClassName);// tAbstractType.get return new CellValidator(validatorClassName, kind, validatorTypes, cqlTypeName); } }
public class class_name { public static <T> CellValidator cellValidator(T obj) { if (obj == null) { return null; // depends on control dependency: [if], data = [none] } Kind kind = Kind.objectToKind(obj); AbstractType<?> tAbstractType = CassandraUtils.marshallerInstance(obj); String validatorClassName = tAbstractType.getClass().getCanonicalName(); Collection<String> validatorTypes = null; DataType.Name cqlTypeName = MAP_JAVA_TYPE_TO_DATA_TYPE_NAME.get(validatorClassName);// tAbstractType.get return new CellValidator(validatorClassName, kind, validatorTypes, cqlTypeName); } }
public class class_name { Node createGetProps(Node receiver, String firstPropName, String... otherPropNames) { Node result = createGetProp(receiver, firstPropName); for (String propertyName : otherPropNames) { result = createGetProp(result, propertyName); } return result; } }
public class class_name { Node createGetProps(Node receiver, String firstPropName, String... otherPropNames) { Node result = createGetProp(receiver, firstPropName); for (String propertyName : otherPropNames) { result = createGetProp(result, propertyName); // depends on control dependency: [for], data = [propertyName] } return result; } }
public class class_name { @Override public <R> MethodResult<R> run(Callable<R> callable) { if (!semaphore.tryAcquire()) { metrics.incrementBulkheadRejectedCount(); return MethodResult.failure(new BulkheadException()); } long startTime = System.nanoTime(); metrics.incrementBulkeadAcceptedCount(); try { return super.run(callable); } finally { semaphore.release(); long endTime = System.nanoTime(); metrics.recordBulkheadExecutionTime(endTime - startTime); } } }
public class class_name { @Override public <R> MethodResult<R> run(Callable<R> callable) { if (!semaphore.tryAcquire()) { metrics.incrementBulkheadRejectedCount(); // depends on control dependency: [if], data = [none] return MethodResult.failure(new BulkheadException()); // depends on control dependency: [if], data = [none] } long startTime = System.nanoTime(); metrics.incrementBulkeadAcceptedCount(); try { return super.run(callable); // depends on control dependency: [try], data = [none] } finally { semaphore.release(); long endTime = System.nanoTime(); metrics.recordBulkheadExecutionTime(endTime - startTime); } } }
public class class_name { @Override protected void deltaScheduleWorkAccepted() { if (trace) log.trace("deltaScheduleWorkAccepted"); super.deltaScheduleWorkAccepted(); if (distributedStatisticsEnabled && distributedStatistics != null && transport != null) { try { checkTransport(); distributedStatistics.sendDeltaScheduleWorkAccepted(); } catch (WorkException we) { log.debugf("deltaScheduleWorkAccepted: %s", we.getMessage(), we); } } } }
public class class_name { @Override protected void deltaScheduleWorkAccepted() { if (trace) log.trace("deltaScheduleWorkAccepted"); super.deltaScheduleWorkAccepted(); if (distributedStatisticsEnabled && distributedStatistics != null && transport != null) { try { checkTransport(); // depends on control dependency: [try], data = [none] distributedStatistics.sendDeltaScheduleWorkAccepted(); // depends on control dependency: [try], data = [none] } catch (WorkException we) { log.debugf("deltaScheduleWorkAccepted: %s", we.getMessage(), we); } // depends on control dependency: [catch], data = [none] } } }
public class class_name { @Override protected Measurement[] getModelMeasurementsImpl() { Measurement[] measurements = new Measurement[this.maxStoredCount]; for (int m = 0; m < this.maxMemberCount; m++) { measurements[m] = new Measurement("Member weight " + (m + 1), -1); } for (int s = this.maxMemberCount; s < this.maxStoredCount; s++) { measurements[s] = new Measurement("Stored member weight " + (s + 1), -1); } if (this.storedWeights != null) { int storeSize = this.storedWeights.length; for (int i = 0; i < storeSize; i++) { if (i < this.ensemble.length) { measurements[i] = new Measurement("Member weight " + (i + 1), this.storedWeights[storeSize - i - 1][0]); } else { measurements[i] = new Measurement("Stored member weight " + (i + 1), this.storedWeights[storeSize - i - 1][0]); } } } return measurements; } }
public class class_name { @Override protected Measurement[] getModelMeasurementsImpl() { Measurement[] measurements = new Measurement[this.maxStoredCount]; for (int m = 0; m < this.maxMemberCount; m++) { measurements[m] = new Measurement("Member weight " + (m + 1), -1); // depends on control dependency: [for], data = [m] } for (int s = this.maxMemberCount; s < this.maxStoredCount; s++) { measurements[s] = new Measurement("Stored member weight " + (s + 1), -1); // depends on control dependency: [for], data = [s] } if (this.storedWeights != null) { int storeSize = this.storedWeights.length; for (int i = 0; i < storeSize; i++) { if (i < this.ensemble.length) { measurements[i] = new Measurement("Member weight " + (i + 1), this.storedWeights[storeSize - i - 1][0]); // depends on control dependency: [if], data = [(i] } else { measurements[i] = new Measurement("Stored member weight " + (i + 1), this.storedWeights[storeSize - i - 1][0]); // depends on control dependency: [if], data = [(i] } } } return measurements; } }
public class class_name { public static String stringify(final JsonNode json) { try { return json != null ? createObjectMapper().writeValueAsString(json) : "{}"; } catch (JsonProcessingException jpx) { throw new RuntimeException("A problem occurred while stringifying a JsonNode: " + jpx.getMessage(), jpx); } } }
public class class_name { public static String stringify(final JsonNode json) { try { return json != null ? createObjectMapper().writeValueAsString(json) : "{}"; // depends on control dependency: [try], data = [none] } catch (JsonProcessingException jpx) { throw new RuntimeException("A problem occurred while stringifying a JsonNode: " + jpx.getMessage(), jpx); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public MemberSelector reset() { if (selectionsIterator != null) { this.selections = strategy.selectConnections(leader, Lists.newLinkedList(members)); this.selectionsIterator = null; } return this; } }
public class class_name { public MemberSelector reset() { if (selectionsIterator != null) { this.selections = strategy.selectConnections(leader, Lists.newLinkedList(members)); // depends on control dependency: [if], data = [none] this.selectionsIterator = null; // depends on control dependency: [if], data = [none] } return this; } }
public class class_name { public boolean isNew(String identifier) { ItemState lastState = changesLog.getItemState(identifier); if (lastState == null || lastState.isDeleted()) { return false; } return changesLog.getItemState(identifier, ItemState.ADDED) != null; } }
public class class_name { public boolean isNew(String identifier) { ItemState lastState = changesLog.getItemState(identifier); if (lastState == null || lastState.isDeleted()) { return false; // depends on control dependency: [if], data = [none] } return changesLog.getItemState(identifier, ItemState.ADDED) != null; } }
public class class_name { private boolean isHeaderinSuppressedHeadersList(String headername) { if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){ checkRequestObjectInUse(); } boolean suppressHeader = false; if(headername != null){ Iterator itList = suppressheadersList.iterator(); while (itList.hasNext() && !(suppressHeader)) { String s = (String) itList.next(); if (headername.startsWith(s)) { suppressHeader = true; if (TraceComponent.isAnyTracingEnabled() && logger.isLoggable (Level.FINE)) logger.logp(Level.FINE, CLASS_NAME, "isHeaderinSuppressedHeadersList", " suppressHeadersInRequest is set and headername --> "+ headername +" begins with --> " + s); } } } return suppressHeader; } }
public class class_name { private boolean isHeaderinSuppressedHeadersList(String headername) { if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){ checkRequestObjectInUse(); // depends on control dependency: [if], data = [none] } boolean suppressHeader = false; if(headername != null){ Iterator itList = suppressheadersList.iterator(); while (itList.hasNext() && !(suppressHeader)) { String s = (String) itList.next(); if (headername.startsWith(s)) { suppressHeader = true; // depends on control dependency: [if], data = [none] if (TraceComponent.isAnyTracingEnabled() && logger.isLoggable (Level.FINE)) logger.logp(Level.FINE, CLASS_NAME, "isHeaderinSuppressedHeadersList", " suppressHeadersInRequest is set and headername --> "+ headername +" begins with --> " + s); } } } return suppressHeader; } }
public class class_name { @Override public void afterCompletion(int status) { if (tc.isEntryEnabled()) { Tr.entry(this, tc, "afterCompletion"); } if (tc.isDebugEnabled()) { Tr.debug( tc, "Using transaction wrapper@" + Integer.toHexString(this.hashCode())); } if (mcWrapper.isMCAborted()) { Tr.exit(tc, "Connection was aborted. Exiting afterCompletion."); return; } // When afterCompletionCode is called we need to reset the registeredForSync flag. registeredForSync = false; this.hasRollbackOccured = false; /* * Mark the transaction complete in the wrapper */ // Do NOT catch runtime exections here. Let them flow out of the component. mcWrapper.transactionComplete(); if (tc.isDebugEnabled()) { if (mcWrapper.getHandleCount() != 0) { // Issue warning that Connections have not been closed by the end of the current UOW // scope and will be closed by the CM. // Tr.warning(this, tc,"HANDLE_NOT_CLOSED_J2CA0055"); Tr.debug(this, tc, "Information: handle not closed at end of UOW. Connection from pool " + mcWrapper.gConfigProps.getXpathId()); } } // Do NOT catch the runtime exception which getConnectionManager might throw. // If this is thrown it is an internal bug and needs to be fixed. // Allow the rte to flow up to the container. boolean shareable = mcWrapper.getConnectionManager().shareable(); // - Simplified the following if/else construct taking advantage of the // new releaseToPoolManger call on mcWrapper. // // If the connection is shareable, or it is non-shareable and the handleCount is // zero, then release it back to the poolManger, otherwise simply reset the // transaction related variables. // // Note: shareable connections are released at the end of transactions regardless of // outstanding handles because we don't supports handled being associated to an active // managedConnection outside of a sharing boundary. // // if the MCWrapper is stale we will release the connection to the pool. // if ((shareable) || (!shareable && mcWrapper.getHandleCount() == 0) || mcWrapper.isStale()) { if (tc.isDebugEnabled()) { Tr.debug(this, tc, "Releasing the connection to the pool. shareable = " + shareable + " handleCount = " + mcWrapper.getHandleCount() + " isStale = " + mcWrapper.isStale()); } try { mcWrapper.releaseToPoolManager(); } catch (Exception e) { // No need to rethrow this exception since nothing can be done about it, // and the application has successfully finished its use of the connection. com.ibm.ws.ffdc.FFDCFilter.processException( e, "com.ibm.ejs.j2c.LocalTransactionWrapper.afterCompletion", "711", this); if (tc.isDebugEnabled()) { Tr.debug(this, tc, "afterCompletionCode for datasource " + mcWrapper.gConfigProps.cfName + ": caught Exception", e); } } } // end ((shareable) || (!shareable && mcWrapper.getHandleCount() == 0)) else { /* * The cleanup of the coordinator enlisted flag should only be done for non sharable connections, in * other cases, the coord is set to null in mcWrapper.releaseToPoolManager(). We only need to worry about this * if the handleCount is greater than 0 (in which case the cleanup will be done by the poolManager). Same * thing for the tranFailed flag in the MCWrapper. */ mcWrapper.setUOWCoordinator(null); // Reset the serialReuseCount since it is only valid for the duration of // the LTC. Note that the release path above will also reset it via mcWrapper.cleanup(). enlisted = false; } if (tc.isEntryEnabled()) { Tr.exit(this, tc, "afterCompletion"); } } }
public class class_name { @Override public void afterCompletion(int status) { if (tc.isEntryEnabled()) { Tr.entry(this, tc, "afterCompletion"); // depends on control dependency: [if], data = [none] } if (tc.isDebugEnabled()) { Tr.debug( tc, "Using transaction wrapper@" + Integer.toHexString(this.hashCode())); // depends on control dependency: [if], data = [none] } if (mcWrapper.isMCAborted()) { Tr.exit(tc, "Connection was aborted. Exiting afterCompletion."); // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } // When afterCompletionCode is called we need to reset the registeredForSync flag. registeredForSync = false; this.hasRollbackOccured = false; /* * Mark the transaction complete in the wrapper */ // Do NOT catch runtime exections here. Let them flow out of the component. mcWrapper.transactionComplete(); if (tc.isDebugEnabled()) { if (mcWrapper.getHandleCount() != 0) { // Issue warning that Connections have not been closed by the end of the current UOW // scope and will be closed by the CM. // Tr.warning(this, tc,"HANDLE_NOT_CLOSED_J2CA0055"); Tr.debug(this, tc, "Information: handle not closed at end of UOW. Connection from pool " + mcWrapper.gConfigProps.getXpathId()); // depends on control dependency: [if], data = [none] } } // Do NOT catch the runtime exception which getConnectionManager might throw. // If this is thrown it is an internal bug and needs to be fixed. // Allow the rte to flow up to the container. boolean shareable = mcWrapper.getConnectionManager().shareable(); // - Simplified the following if/else construct taking advantage of the // new releaseToPoolManger call on mcWrapper. // // If the connection is shareable, or it is non-shareable and the handleCount is // zero, then release it back to the poolManger, otherwise simply reset the // transaction related variables. // // Note: shareable connections are released at the end of transactions regardless of // outstanding handles because we don't supports handled being associated to an active // managedConnection outside of a sharing boundary. // // if the MCWrapper is stale we will release the connection to the pool. // if ((shareable) || (!shareable && mcWrapper.getHandleCount() == 0) || mcWrapper.isStale()) { if (tc.isDebugEnabled()) { Tr.debug(this, tc, "Releasing the connection to the pool. shareable = " + shareable + " handleCount = " + mcWrapper.getHandleCount() + " isStale = " + mcWrapper.isStale()); // depends on control dependency: [if], data = [none] } try { mcWrapper.releaseToPoolManager(); // depends on control dependency: [try], data = [none] } catch (Exception e) { // No need to rethrow this exception since nothing can be done about it, // and the application has successfully finished its use of the connection. com.ibm.ws.ffdc.FFDCFilter.processException( e, "com.ibm.ejs.j2c.LocalTransactionWrapper.afterCompletion", "711", this); if (tc.isDebugEnabled()) { Tr.debug(this, tc, "afterCompletionCode for datasource " + mcWrapper.gConfigProps.cfName + ": caught Exception", e); // depends on control dependency: [if], data = [none] } } // depends on control dependency: [catch], data = [none] } // end ((shareable) || (!shareable && mcWrapper.getHandleCount() == 0)) else { /* * The cleanup of the coordinator enlisted flag should only be done for non sharable connections, in * other cases, the coord is set to null in mcWrapper.releaseToPoolManager(). We only need to worry about this * if the handleCount is greater than 0 (in which case the cleanup will be done by the poolManager). Same * thing for the tranFailed flag in the MCWrapper. */ mcWrapper.setUOWCoordinator(null); // depends on control dependency: [if], data = [none] // Reset the serialReuseCount since it is only valid for the duration of // the LTC. Note that the release path above will also reset it via mcWrapper.cleanup(). enlisted = false; // depends on control dependency: [if], data = [none] } if (tc.isEntryEnabled()) { Tr.exit(this, tc, "afterCompletion"); // depends on control dependency: [if], data = [none] } } }
public class class_name { public void marshall(DeleteDirectConnectGatewayRequest deleteDirectConnectGatewayRequest, ProtocolMarshaller protocolMarshaller) { if (deleteDirectConnectGatewayRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(deleteDirectConnectGatewayRequest.getDirectConnectGatewayId(), DIRECTCONNECTGATEWAYID_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } } }
public class class_name { public void marshall(DeleteDirectConnectGatewayRequest deleteDirectConnectGatewayRequest, ProtocolMarshaller protocolMarshaller) { if (deleteDirectConnectGatewayRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(deleteDirectConnectGatewayRequest.getDirectConnectGatewayId(), DIRECTCONNECTGATEWAYID_BINDING); // depends on control dependency: [try], data = [none] } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { private List<CmsSelectWidgetOption> getProjectWidgetConfiguration() { List<CmsSelectWidgetOption> result = new ArrayList<CmsSelectWidgetOption>(); try { List<CmsProject> projects = OpenCms.getOrgUnitManager().getAllManageableProjects(getCms(), "", true); projects.add(getCms().readProject(CmsProject.ONLINE_PROJECT_ID)); for (CmsProject project : projects) { CmsSelectWidgetOption option = new CmsSelectWidgetOption(project.getName(), project.equals(project)); result.add(option); } } catch (CmsException e) { // should never happen } return result; } }
public class class_name { private List<CmsSelectWidgetOption> getProjectWidgetConfiguration() { List<CmsSelectWidgetOption> result = new ArrayList<CmsSelectWidgetOption>(); try { List<CmsProject> projects = OpenCms.getOrgUnitManager().getAllManageableProjects(getCms(), "", true); projects.add(getCms().readProject(CmsProject.ONLINE_PROJECT_ID)); // depends on control dependency: [try], data = [none] for (CmsProject project : projects) { CmsSelectWidgetOption option = new CmsSelectWidgetOption(project.getName(), project.equals(project)); result.add(option); // depends on control dependency: [for], data = [none] } } catch (CmsException e) { // should never happen } // depends on control dependency: [catch], data = [none] return result; } }
public class class_name { public Collection<User> list(String name, String role) { List<User> ret = new ArrayList<User>(); Collection<User> users = list(); for(User user : users) { if((name == null || user.getName().toLowerCase().indexOf(name) != -1) && (role == null || user.getRole().equals(role))) { ret.add(user); } } return ret; } }
public class class_name { public Collection<User> list(String name, String role) { List<User> ret = new ArrayList<User>(); Collection<User> users = list(); for(User user : users) { if((name == null || user.getName().toLowerCase().indexOf(name) != -1) && (role == null || user.getRole().equals(role))) { ret.add(user); // depends on control dependency: [if], data = [none] } } return ret; } }
public class class_name { public static HttpContextActivationFilter getContextActivationFilter(BeanManagerImpl manager, ServletContext context) { HttpContextActivationFilter filter = manager.getServices().get(HttpContextActivationFilter.class); final String pattern = context.getInitParameter(InitParameters.CONTEXT_MAPPING); if (filter == AcceptingHttpContextActivationFilter.INSTANCE) { // SPI has precedence. If a filter was not set through SPI let's see if a mapping is set in web.xml if (pattern != null) { return new RegexHttpContextActivationFilter(pattern); } } else if (pattern != null) { ServletLogger.LOG.webXmlMappingPatternIgnored(pattern); } return filter; } }
public class class_name { public static HttpContextActivationFilter getContextActivationFilter(BeanManagerImpl manager, ServletContext context) { HttpContextActivationFilter filter = manager.getServices().get(HttpContextActivationFilter.class); final String pattern = context.getInitParameter(InitParameters.CONTEXT_MAPPING); if (filter == AcceptingHttpContextActivationFilter.INSTANCE) { // SPI has precedence. If a filter was not set through SPI let's see if a mapping is set in web.xml if (pattern != null) { return new RegexHttpContextActivationFilter(pattern); // depends on control dependency: [if], data = [(pattern] } } else if (pattern != null) { ServletLogger.LOG.webXmlMappingPatternIgnored(pattern); // depends on control dependency: [if], data = [(pattern] } return filter; } }
public class class_name { @Override public void run() { int received; // noinspection InfiniteLoopStatement while (true) { // System.out.println("In PollThread loop (sleep=" + sleep + // ")...."); try { if (sleep != 0) { received = get_command(sleep); } else { received = POLL_TIME_OUT; } long ctm = System.currentTimeMillis(); now.tv_sec = (int) (ctm / 1000); now.tv_usec = (int) (ctm - 1000 * now.tv_sec) * 1000; now.tv_sec = now.tv_sec - Tango_DELTA_T; switch (received) { case POLL_COMMAND: execute_cmd(); break; case POLL_TIME_OUT: one_more_poll(); break; case POLL_TRIGGER: one_more_trigg(); break; } ctm = System.currentTimeMillis(); after.tv_sec = (int) (ctm / 1000); after.tv_usec = (int) (ctm - 1000 * after.tv_sec) * 1000; after.tv_sec = after.tv_sec - Tango_DELTA_T; compute_sleep_time(); } catch (final DevFailed e) { Util.out2.println("OUPS !! A thread fatal exception !!!!!!!!"); Except.print_exception(e); Util.out2.println("Trying to re-enter the main loop"); } } } }
public class class_name { @Override public void run() { int received; // noinspection InfiniteLoopStatement while (true) { // System.out.println("In PollThread loop (sleep=" + sleep + // ")...."); try { if (sleep != 0) { received = get_command(sleep); // depends on control dependency: [if], data = [(sleep] } else { received = POLL_TIME_OUT; // depends on control dependency: [if], data = [none] } long ctm = System.currentTimeMillis(); now.tv_sec = (int) (ctm / 1000); // depends on control dependency: [try], data = [none] now.tv_usec = (int) (ctm - 1000 * now.tv_sec) * 1000; // depends on control dependency: [try], data = [none] now.tv_sec = now.tv_sec - Tango_DELTA_T; // depends on control dependency: [try], data = [none] switch (received) { case POLL_COMMAND: execute_cmd(); break; case POLL_TIME_OUT: one_more_poll(); break; case POLL_TRIGGER: one_more_trigg(); break; } ctm = System.currentTimeMillis(); // depends on control dependency: [try], data = [none] after.tv_sec = (int) (ctm / 1000); // depends on control dependency: [try], data = [none] after.tv_usec = (int) (ctm - 1000 * after.tv_sec) * 1000; // depends on control dependency: [try], data = [none] after.tv_sec = after.tv_sec - Tango_DELTA_T; // depends on control dependency: [try], data = [none] compute_sleep_time(); // depends on control dependency: [try], data = [none] } catch (final DevFailed e) { Util.out2.println("OUPS !! A thread fatal exception !!!!!!!!"); Except.print_exception(e); Util.out2.println("Trying to re-enter the main loop"); } // depends on control dependency: [catch], data = [none] } } }
public class class_name { public static float min(final float a, final float b) { if (Float.isNaN(a)) { return b; } else if (Float.isNaN(b)) { return a; } else { return Math.min(a, b); } } }
public class class_name { public static float min(final float a, final float b) { if (Float.isNaN(a)) { return b; // depends on control dependency: [if], data = [none] } else if (Float.isNaN(b)) { return a; // depends on control dependency: [if], data = [none] } else { return Math.min(a, b); // depends on control dependency: [if], data = [none] } } }
public class class_name { private String getDirectory(String timedObjectId) { String dirName = directories.get(timedObjectId); if (dirName == null) { dirName = baseDir.getAbsolutePath() + File.separator + timedObjectId.replace(File.separator, "-"); File file = new File(dirName); if (!file.exists()) { if (!file.mkdirs()) { EJB3_TIMER_LOGGER.failToCreateDirectoryForPersistTimers(file); } } directories.put(timedObjectId, dirName); } return dirName; } }
public class class_name { private String getDirectory(String timedObjectId) { String dirName = directories.get(timedObjectId); if (dirName == null) { dirName = baseDir.getAbsolutePath() + File.separator + timedObjectId.replace(File.separator, "-"); // depends on control dependency: [if], data = [none] File file = new File(dirName); if (!file.exists()) { if (!file.mkdirs()) { EJB3_TIMER_LOGGER.failToCreateDirectoryForPersistTimers(file); // depends on control dependency: [if], data = [none] } } directories.put(timedObjectId, dirName); // depends on control dependency: [if], data = [none] } return dirName; } }
public class class_name { public static void asyncExecute(Runnable runnable) { if (runnable != null) { try { Para.getExecutorService().execute(runnable); } catch (RejectedExecutionException ex) { logger.warn(ex.getMessage()); try { runnable.run(); } catch (Exception e) { logger.error(null, e); } } } } }
public class class_name { public static void asyncExecute(Runnable runnable) { if (runnable != null) { try { Para.getExecutorService().execute(runnable); // depends on control dependency: [try], data = [none] } catch (RejectedExecutionException ex) { logger.warn(ex.getMessage()); try { runnable.run(); // depends on control dependency: [try], data = [none] } catch (Exception e) { logger.error(null, e); } // depends on control dependency: [catch], data = [none] } // depends on control dependency: [catch], data = [none] } } }
public class class_name { private void needNewBuffer(int newSize) { int delta = newSize - size; int newBufferSize = Math.max(minChunkLen, delta); currentBufferIndex++; currentBuffer = (E[]) new Object[newBufferSize]; offset = 0; // add buffer if (currentBufferIndex >= buffers.length) { int newLen = buffers.length << 1; E[][] newBuffers = (E[][]) new Object[newLen][]; System.arraycopy(buffers, 0, newBuffers, 0, buffers.length); buffers = newBuffers; } buffers[currentBufferIndex] = currentBuffer; buffersCount++; } }
public class class_name { private void needNewBuffer(int newSize) { int delta = newSize - size; int newBufferSize = Math.max(minChunkLen, delta); currentBufferIndex++; currentBuffer = (E[]) new Object[newBufferSize]; offset = 0; // add buffer if (currentBufferIndex >= buffers.length) { int newLen = buffers.length << 1; E[][] newBuffers = (E[][]) new Object[newLen][]; System.arraycopy(buffers, 0, newBuffers, 0, buffers.length); // depends on control dependency: [if], data = [none] buffers = newBuffers; // depends on control dependency: [if], data = [none] } buffers[currentBufferIndex] = currentBuffer; buffersCount++; } }
public class class_name { public void realInverseFull(final float[] a, final int offa, boolean scale) { final int twon = 2 * n; switch (plan) { case SPLIT_RADIX:{ realInverse2(a, offa, scale); int idx1, idx2; for (int k = 0; k < n / 2; k++) { idx1 = 2 * k; idx2 = offa + ((twon - idx1) % twon); a[idx2] = a[offa + idx1]; a[idx2 + 1] = -a[offa + idx1 + 1]; } a[offa + n] = -a[offa + 1]; a[offa + 1] = 0; }break; case MIXED_RADIX: rfftf(a, offa); if (scale) { scale(n, a, offa, false); } int m; if (n % 2 == 0) { m = n / 2; } else { m = (n + 1) / 2; } for (int k = 1; k < m; k++) { int idx1 = offa + 2 * k; int idx2 = offa + twon - 2 * k; a[idx1] = -a[idx1]; a[idx2 + 1] = -a[idx1]; a[idx2] = a[idx1 - 1]; } for (int k = 1; k < n; k++) { int idx = offa + n - k; float tmp = a[idx + 1]; a[idx + 1] = a[idx]; a[idx] = tmp; } a[offa + 1] = 0; break; case BLUESTEIN: bluestein_real_full(a, offa, 1); if (scale) { scale(n, a, offa, true); } break; } } }
public class class_name { public void realInverseFull(final float[] a, final int offa, boolean scale) { final int twon = 2 * n; switch (plan) { case SPLIT_RADIX:{ realInverse2(a, offa, scale); int idx1, idx2; for (int k = 0; k < n / 2; k++) { idx1 = 2 * k; // depends on control dependency: [for], data = [k] idx2 = offa + ((twon - idx1) % twon); // depends on control dependency: [for], data = [none] a[idx2] = a[offa + idx1]; // depends on control dependency: [for], data = [none] a[idx2 + 1] = -a[offa + idx1 + 1]; // depends on control dependency: [for], data = [none] } a[offa + n] = -a[offa + 1]; a[offa + 1] = 0; }break; case MIXED_RADIX: rfftf(a, offa); if (scale) { scale(n, a, offa, false); // depends on control dependency: [if], data = [none] } int m; if (n % 2 == 0) { m = n / 2; // depends on control dependency: [if], data = [none] } else { m = (n + 1) / 2; // depends on control dependency: [if], data = [none] } for (int k = 1; k < m; k++) { int idx1 = offa + 2 * k; int idx2 = offa + twon - 2 * k; a[idx1] = -a[idx1]; // depends on control dependency: [for], data = [none] a[idx2 + 1] = -a[idx1]; // depends on control dependency: [for], data = [none] a[idx2] = a[idx1 - 1]; // depends on control dependency: [for], data = [none] } for (int k = 1; k < n; k++) { int idx = offa + n - k; float tmp = a[idx + 1]; a[idx + 1] = a[idx]; // depends on control dependency: [for], data = [none] a[idx] = tmp; // depends on control dependency: [for], data = [none] } a[offa + 1] = 0; break; case BLUESTEIN: bluestein_real_full(a, offa, 1); if (scale) { scale(n, a, offa, true); // depends on control dependency: [if], data = [none] } break; } } }
public class class_name { protected String createSQLStatement() throws EFapsException { final SQLSelect select = new SQLSelect() .column(0, "ID") .from(getBaseType().getMainTable().getSqlTable(), 0); // if the main table has a column for the type it is selected also if (getBaseType().getMainTable().getSqlColType() != null) { select.column(0, getBaseType().getMainTable().getSqlColType()); } // add child tables if (getSqlTable2Index().size() > 0) { for (final Entry<SQLTable, Integer> entry : getSqlTable2Index().entrySet()) { if (entry.getValue() > 0) { select.leftJoin(entry.getKey().getSqlTable(), entry.getValue(), "ID", 0, "ID"); } } } select.addSection(getWhere()); select.addSection(getOrderBy()); select.addSection(getLimit()); return select.getSQL(); } }
public class class_name { protected String createSQLStatement() throws EFapsException { final SQLSelect select = new SQLSelect() .column(0, "ID") .from(getBaseType().getMainTable().getSqlTable(), 0); // if the main table has a column for the type it is selected also if (getBaseType().getMainTable().getSqlColType() != null) { select.column(0, getBaseType().getMainTable().getSqlColType()); } // add child tables if (getSqlTable2Index().size() > 0) { for (final Entry<SQLTable, Integer> entry : getSqlTable2Index().entrySet()) { if (entry.getValue() > 0) { select.leftJoin(entry.getKey().getSqlTable(), entry.getValue(), "ID", 0, "ID"); // depends on control dependency: [if], data = [none] } } } select.addSection(getWhere()); select.addSection(getOrderBy()); select.addSection(getLimit()); return select.getSQL(); } }
public class class_name { public static int asciiSizeInBytes(long v) { if (v == 0) return 1; if (v == Long.MIN_VALUE) return 20; boolean negative = false; if (v < 0) { v = -v; // making this positive allows us to compare using less-than negative = true; } int width = v < 100000000L ? v < 10000L ? v < 100L ? v < 10L ? 1 : 2 : v < 1000L ? 3 : 4 : v < 1000000L ? v < 100000L ? 5 : 6 : v < 10000000L ? 7 : 8 : v < 1000000000000L ? v < 10000000000L ? v < 1000000000L ? 9 : 10 : v < 100000000000L ? 11 : 12 : v < 1000000000000000L ? v < 10000000000000L ? 13 : v < 100000000000000L ? 14 : 15 : v < 100000000000000000L ? v < 10000000000000000L ? 16 : 17 : v < 1000000000000000000L ? 18 : 19; return negative ? width + 1 : width; // conditionally add room for negative sign } }
public class class_name { public static int asciiSizeInBytes(long v) { if (v == 0) return 1; if (v == Long.MIN_VALUE) return 20; boolean negative = false; if (v < 0) { v = -v; // making this positive allows us to compare using less-than // depends on control dependency: [if], data = [none] negative = true; // depends on control dependency: [if], data = [none] } int width = v < 100000000L ? v < 10000L ? v < 100L ? v < 10L ? 1 : 2 : v < 1000L ? 3 : 4 : v < 1000000L ? v < 100000L ? 5 : 6 : v < 10000000L ? 7 : 8 : v < 1000000000000L ? v < 10000000000L ? v < 1000000000L ? 9 : 10 : v < 100000000000L ? 11 : 12 : v < 1000000000000000L ? v < 10000000000000L ? 13 : v < 100000000000000L ? 14 : 15 : v < 100000000000000000L ? v < 10000000000000000L ? 16 : 17 : v < 1000000000000000000L ? 18 : 19; return negative ? width + 1 : width; // conditionally add room for negative sign } }
public class class_name { private HttpHandler setupSecurityHandlers(HttpHandler initialHandler) { final DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); final LoginConfig loginConfig = deploymentInfo.getLoginConfig(); HttpHandler current = initialHandler; current = new SSLInformationAssociationHandler(current); final SecurityPathMatches securityPathMatches = buildSecurityConstraints(); securityPathMatches.logWarningsAboutUncoveredMethods(); current = new ServletAuthenticationCallHandler(current); for(HandlerWrapper wrapper : deploymentInfo.getSecurityWrappers()) { current = wrapper.wrap(current); } if(deploymentInfo.isDisableCachingForSecuredPages()) { current = Handlers.predicate(Predicates.authRequired(), Handlers.disableCache(current), current); } if (!securityPathMatches.isEmpty()) { current = new ServletAuthenticationConstraintHandler(current); } current = new ServletConfidentialityConstraintHandler(deploymentInfo.getConfidentialPortManager(), current); if (!securityPathMatches.isEmpty()) { current = new ServletSecurityConstraintHandler(securityPathMatches, current); } HandlerWrapper initialSecurityWrapper = deploymentInfo.getInitialSecurityWrapper(); String mechName = null; if (initialSecurityWrapper == null) { final Map<String, AuthenticationMechanismFactory> factoryMap = new HashMap<>(deploymentInfo.getAuthenticationMechanisms()); final IdentityManager identityManager = deploymentInfo.getIdentityManager(); if(!factoryMap.containsKey(BASIC_AUTH)) { factoryMap.put(BASIC_AUTH, BasicAuthenticationMechanism.FACTORY); } if(!factoryMap.containsKey(FORM_AUTH)) { factoryMap.put(FORM_AUTH, ServletFormAuthenticationMechanism.FACTORY); } if(!factoryMap.containsKey(DIGEST_AUTH)) { factoryMap.put(DIGEST_AUTH, DigestAuthenticationMechanism.FACTORY); } if(!factoryMap.containsKey(CLIENT_CERT_AUTH)) { factoryMap.put(CLIENT_CERT_AUTH, ClientCertAuthenticationMechanism.FACTORY); } if(!factoryMap.containsKey(ExternalAuthenticationMechanism.NAME)) { factoryMap.put(ExternalAuthenticationMechanism.NAME, ExternalAuthenticationMechanism.FACTORY); } if(!factoryMap.containsKey(GenericHeaderAuthenticationMechanism.NAME)) { factoryMap.put(GenericHeaderAuthenticationMechanism.NAME, GenericHeaderAuthenticationMechanism.FACTORY); } List<AuthenticationMechanism> authenticationMechanisms = new LinkedList<>(); if(deploymentInfo.isUseCachedAuthenticationMechanism()) { authenticationMechanisms.add(new CachedAuthenticatedSessionMechanism(identityManager)); } if (loginConfig != null || deploymentInfo.getJaspiAuthenticationMechanism() != null) { //we don't allow multipart requests, and use the default encoding when it's set FormEncodedDataDefinition formEncodedDataDefinition = new FormEncodedDataDefinition(); String reqEncoding = deploymentInfo.getDefaultRequestEncoding(); if(reqEncoding == null) { reqEncoding = deploymentInfo.getDefaultEncoding(); } if (reqEncoding != null) { formEncodedDataDefinition.setDefaultEncoding(reqEncoding); } FormParserFactory parser = FormParserFactory.builder(false) .addParser(formEncodedDataDefinition) .build(); List<AuthMethodConfig> authMethods = Collections.<AuthMethodConfig>emptyList(); if(loginConfig != null) { authMethods = loginConfig.getAuthMethods(); } for(AuthMethodConfig method : authMethods) { AuthenticationMechanismFactory factory = factoryMap.get(method.getName()); if(factory == null) { throw UndertowServletMessages.MESSAGES.unknownAuthenticationMechanism(method.getName()); } if(mechName == null) { mechName = method.getName(); } final Map<String, String> properties = new HashMap<>(); properties.put(AuthenticationMechanismFactory.CONTEXT_PATH, deploymentInfo.getContextPath()); properties.put(AuthenticationMechanismFactory.REALM, loginConfig.getRealmName()); properties.put(AuthenticationMechanismFactory.ERROR_PAGE, loginConfig.getErrorPage()); properties.put(AuthenticationMechanismFactory.LOGIN_PAGE, loginConfig.getLoginPage()); properties.putAll(method.getProperties()); String name = method.getName().toUpperCase(Locale.US); // The mechanism name is passed in from the HttpServletRequest interface as the name reported needs to be // comparable using '==' name = name.equals(FORM_AUTH) ? FORM_AUTH : name; name = name.equals(BASIC_AUTH) ? BASIC_AUTH : name; name = name.equals(DIGEST_AUTH) ? DIGEST_AUTH : name; name = name.equals(CLIENT_CERT_AUTH) ? CLIENT_CERT_AUTH : name; authenticationMechanisms.add(factory.create(name, identityManager, parser, properties)); } } deployment.setAuthenticationMechanisms(authenticationMechanisms); //if the JASPI auth mechanism is set then it takes over if(deploymentInfo.getJaspiAuthenticationMechanism() == null) { current = new AuthenticationMechanismsHandler(current, authenticationMechanisms); } else { current = new AuthenticationMechanismsHandler(current, Collections.<AuthenticationMechanism>singletonList(deploymentInfo.getJaspiAuthenticationMechanism())); } current = new CachedAuthenticatedSessionHandler(current, this.deployment.getServletContext()); } List<NotificationReceiver> notificationReceivers = deploymentInfo.getNotificationReceivers(); if (!notificationReceivers.isEmpty()) { current = new NotificationReceiverHandler(current, notificationReceivers); } if (initialSecurityWrapper == null) { // TODO - A switch to constraint driven could be configurable, however before we can support that with servlets we would // need additional tracking within sessions if a servlet has specifically requested that authentication occurs. SecurityContextFactory contextFactory = deploymentInfo.getSecurityContextFactory(); if (contextFactory == null) { contextFactory = SecurityContextFactoryImpl.INSTANCE; } current = new SecurityInitialHandler(deploymentInfo.getAuthenticationMode(), deploymentInfo.getIdentityManager(), mechName, contextFactory, current); } else { current = initialSecurityWrapper.wrap(current); } return current; } }
public class class_name { private HttpHandler setupSecurityHandlers(HttpHandler initialHandler) { final DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); final LoginConfig loginConfig = deploymentInfo.getLoginConfig(); HttpHandler current = initialHandler; current = new SSLInformationAssociationHandler(current); final SecurityPathMatches securityPathMatches = buildSecurityConstraints(); securityPathMatches.logWarningsAboutUncoveredMethods(); current = new ServletAuthenticationCallHandler(current); for(HandlerWrapper wrapper : deploymentInfo.getSecurityWrappers()) { current = wrapper.wrap(current); // depends on control dependency: [for], data = [wrapper] } if(deploymentInfo.isDisableCachingForSecuredPages()) { current = Handlers.predicate(Predicates.authRequired(), Handlers.disableCache(current), current); // depends on control dependency: [if], data = [none] } if (!securityPathMatches.isEmpty()) { current = new ServletAuthenticationConstraintHandler(current); // depends on control dependency: [if], data = [none] } current = new ServletConfidentialityConstraintHandler(deploymentInfo.getConfidentialPortManager(), current); if (!securityPathMatches.isEmpty()) { current = new ServletSecurityConstraintHandler(securityPathMatches, current); // depends on control dependency: [if], data = [none] } HandlerWrapper initialSecurityWrapper = deploymentInfo.getInitialSecurityWrapper(); String mechName = null; if (initialSecurityWrapper == null) { final Map<String, AuthenticationMechanismFactory> factoryMap = new HashMap<>(deploymentInfo.getAuthenticationMechanisms()); final IdentityManager identityManager = deploymentInfo.getIdentityManager(); if(!factoryMap.containsKey(BASIC_AUTH)) { factoryMap.put(BASIC_AUTH, BasicAuthenticationMechanism.FACTORY); // depends on control dependency: [if], data = [none] } if(!factoryMap.containsKey(FORM_AUTH)) { factoryMap.put(FORM_AUTH, ServletFormAuthenticationMechanism.FACTORY); // depends on control dependency: [if], data = [none] } if(!factoryMap.containsKey(DIGEST_AUTH)) { factoryMap.put(DIGEST_AUTH, DigestAuthenticationMechanism.FACTORY); // depends on control dependency: [if], data = [none] } if(!factoryMap.containsKey(CLIENT_CERT_AUTH)) { factoryMap.put(CLIENT_CERT_AUTH, ClientCertAuthenticationMechanism.FACTORY); // depends on control dependency: [if], data = [none] } if(!factoryMap.containsKey(ExternalAuthenticationMechanism.NAME)) { factoryMap.put(ExternalAuthenticationMechanism.NAME, ExternalAuthenticationMechanism.FACTORY); // depends on control dependency: [if], data = [none] } if(!factoryMap.containsKey(GenericHeaderAuthenticationMechanism.NAME)) { factoryMap.put(GenericHeaderAuthenticationMechanism.NAME, GenericHeaderAuthenticationMechanism.FACTORY); // depends on control dependency: [if], data = [none] } List<AuthenticationMechanism> authenticationMechanisms = new LinkedList<>(); if(deploymentInfo.isUseCachedAuthenticationMechanism()) { authenticationMechanisms.add(new CachedAuthenticatedSessionMechanism(identityManager)); // depends on control dependency: [if], data = [none] } if (loginConfig != null || deploymentInfo.getJaspiAuthenticationMechanism() != null) { //we don't allow multipart requests, and use the default encoding when it's set FormEncodedDataDefinition formEncodedDataDefinition = new FormEncodedDataDefinition(); String reqEncoding = deploymentInfo.getDefaultRequestEncoding(); if(reqEncoding == null) { reqEncoding = deploymentInfo.getDefaultEncoding(); // depends on control dependency: [if], data = [none] } if (reqEncoding != null) { formEncodedDataDefinition.setDefaultEncoding(reqEncoding); // depends on control dependency: [if], data = [(reqEncoding] } FormParserFactory parser = FormParserFactory.builder(false) .addParser(formEncodedDataDefinition) .build(); List<AuthMethodConfig> authMethods = Collections.<AuthMethodConfig>emptyList(); if(loginConfig != null) { authMethods = loginConfig.getAuthMethods(); // depends on control dependency: [if], data = [none] } for(AuthMethodConfig method : authMethods) { AuthenticationMechanismFactory factory = factoryMap.get(method.getName()); if(factory == null) { throw UndertowServletMessages.MESSAGES.unknownAuthenticationMechanism(method.getName()); } if(mechName == null) { mechName = method.getName(); // depends on control dependency: [if], data = [none] } final Map<String, String> properties = new HashMap<>(); properties.put(AuthenticationMechanismFactory.CONTEXT_PATH, deploymentInfo.getContextPath()); // depends on control dependency: [for], data = [none] properties.put(AuthenticationMechanismFactory.REALM, loginConfig.getRealmName()); // depends on control dependency: [for], data = [none] properties.put(AuthenticationMechanismFactory.ERROR_PAGE, loginConfig.getErrorPage()); // depends on control dependency: [for], data = [none] properties.put(AuthenticationMechanismFactory.LOGIN_PAGE, loginConfig.getLoginPage()); // depends on control dependency: [for], data = [none] properties.putAll(method.getProperties()); // depends on control dependency: [for], data = [method] String name = method.getName().toUpperCase(Locale.US); // The mechanism name is passed in from the HttpServletRequest interface as the name reported needs to be // comparable using '==' name = name.equals(FORM_AUTH) ? FORM_AUTH : name; // depends on control dependency: [for], data = [none] name = name.equals(BASIC_AUTH) ? BASIC_AUTH : name; // depends on control dependency: [for], data = [none] name = name.equals(DIGEST_AUTH) ? DIGEST_AUTH : name; // depends on control dependency: [for], data = [none] name = name.equals(CLIENT_CERT_AUTH) ? CLIENT_CERT_AUTH : name; // depends on control dependency: [for], data = [none] authenticationMechanisms.add(factory.create(name, identityManager, parser, properties)); // depends on control dependency: [for], data = [none] } } deployment.setAuthenticationMechanisms(authenticationMechanisms); // depends on control dependency: [if], data = [none] //if the JASPI auth mechanism is set then it takes over if(deploymentInfo.getJaspiAuthenticationMechanism() == null) { current = new AuthenticationMechanismsHandler(current, authenticationMechanisms); // depends on control dependency: [if], data = [none] } else { current = new AuthenticationMechanismsHandler(current, Collections.<AuthenticationMechanism>singletonList(deploymentInfo.getJaspiAuthenticationMechanism())); // depends on control dependency: [if], data = [(deploymentInfo.getJaspiAuthenticationMechanism()] } current = new CachedAuthenticatedSessionHandler(current, this.deployment.getServletContext()); // depends on control dependency: [if], data = [none] } List<NotificationReceiver> notificationReceivers = deploymentInfo.getNotificationReceivers(); if (!notificationReceivers.isEmpty()) { current = new NotificationReceiverHandler(current, notificationReceivers); // depends on control dependency: [if], data = [none] } if (initialSecurityWrapper == null) { // TODO - A switch to constraint driven could be configurable, however before we can support that with servlets we would // need additional tracking within sessions if a servlet has specifically requested that authentication occurs. SecurityContextFactory contextFactory = deploymentInfo.getSecurityContextFactory(); if (contextFactory == null) { contextFactory = SecurityContextFactoryImpl.INSTANCE; // depends on control dependency: [if], data = [none] } current = new SecurityInitialHandler(deploymentInfo.getAuthenticationMode(), deploymentInfo.getIdentityManager(), mechName, contextFactory, current); // depends on control dependency: [if], data = [none] } else { current = initialSecurityWrapper.wrap(current); // depends on control dependency: [if], data = [none] } return current; } }
public class class_name { public void marshall(PutActionRevisionRequest putActionRevisionRequest, ProtocolMarshaller protocolMarshaller) { if (putActionRevisionRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(putActionRevisionRequest.getPipelineName(), PIPELINENAME_BINDING); protocolMarshaller.marshall(putActionRevisionRequest.getStageName(), STAGENAME_BINDING); protocolMarshaller.marshall(putActionRevisionRequest.getActionName(), ACTIONNAME_BINDING); protocolMarshaller.marshall(putActionRevisionRequest.getActionRevision(), ACTIONREVISION_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } } }
public class class_name { public void marshall(PutActionRevisionRequest putActionRevisionRequest, ProtocolMarshaller protocolMarshaller) { if (putActionRevisionRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(putActionRevisionRequest.getPipelineName(), PIPELINENAME_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(putActionRevisionRequest.getStageName(), STAGENAME_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(putActionRevisionRequest.getActionName(), ACTIONNAME_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(putActionRevisionRequest.getActionRevision(), ACTIONREVISION_BINDING); // depends on control dependency: [try], data = [none] } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public static String formatSize(double size) { double kiloByte = size / 1024; if (kiloByte < 1) { return size + "Byte"; } double megaByte = kiloByte / 1024; if (megaByte < 1) { BigDecimal result1 = new BigDecimal(Double.toString(kiloByte)); return result1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "KB"; } double gigaByte = megaByte / 1024; if (gigaByte < 1) { BigDecimal result2 = new BigDecimal(Double.toString(megaByte)); return result2.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "MB"; } double teraBytes = gigaByte / 1024; if (teraBytes < 1) { BigDecimal result3 = new BigDecimal(Double.toString(gigaByte)); return result3.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "GB"; } BigDecimal result4 = new BigDecimal(teraBytes); return result4.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "TB"; } }
public class class_name { public static String formatSize(double size) { double kiloByte = size / 1024; if (kiloByte < 1) { return size + "Byte"; // depends on control dependency: [if], data = [none] } double megaByte = kiloByte / 1024; if (megaByte < 1) { BigDecimal result1 = new BigDecimal(Double.toString(kiloByte)); return result1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "KB"; // depends on control dependency: [if], data = [none] } double gigaByte = megaByte / 1024; if (gigaByte < 1) { BigDecimal result2 = new BigDecimal(Double.toString(megaByte)); return result2.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "MB"; // depends on control dependency: [if], data = [none] } double teraBytes = gigaByte / 1024; if (teraBytes < 1) { BigDecimal result3 = new BigDecimal(Double.toString(gigaByte)); return result3.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "GB"; // depends on control dependency: [if], data = [none] } BigDecimal result4 = new BigDecimal(teraBytes); return result4.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "TB"; } }
public class class_name { public PolygonOptions toCurvePolygon(CurvePolygon curvePolygon) { PolygonOptions polygonOptions = new PolygonOptions(); List<Curve> rings = curvePolygon.getRings(); if (!rings.isEmpty()) { Double z = null; // Add the polygon points Curve curve = rings.get(0); if (curve instanceof CompoundCurve) { CompoundCurve compoundCurve = (CompoundCurve) curve; for (LineString lineString : compoundCurve.getLineStrings()) { // Try to simplify the number of points in the compound curve List<Point> points = simplifyPoints(lineString.getPoints()); for (Point point : points) { LatLng latLng = toLatLng(point); polygonOptions.add(latLng); if (point.hasZ()) { z = (z == null) ? point.getZ() : Math.max(z, point.getZ()); } } } } else if (curve instanceof LineString) { LineString lineString = (LineString) curve; // Try to simplify the number of points in the curve List<Point> points = simplifyPoints(lineString.getPoints()); for (Point point : points) { LatLng latLng = toLatLng(point); polygonOptions.add(latLng); if (point.hasZ()) { z = (z == null) ? point.getZ() : Math.max(z, point.getZ()); } } } else { throw new GeoPackageException("Unsupported Curve Type: " + curve.getClass().getSimpleName()); } // Add the holes for (int i = 1; i < rings.size(); i++) { Curve hole = rings.get(i); List<LatLng> holeLatLngs = new ArrayList<LatLng>(); if (hole instanceof CompoundCurve) { CompoundCurve holeCompoundCurve = (CompoundCurve) hole; for (LineString holeLineString : holeCompoundCurve.getLineStrings()) { // Try to simplify the number of points in the hole List<Point> holePoints = simplifyPoints(holeLineString.getPoints()); for (Point point : holePoints) { LatLng latLng = toLatLng(point); holeLatLngs.add(latLng); if (point.hasZ()) { z = (z == null) ? point.getZ() : Math.max(z, point.getZ()); } } } } else if (hole instanceof LineString) { LineString holeLineString = (LineString) hole; // Try to simplify the number of points in the hole List<Point> holePoints = simplifyPoints(holeLineString.getPoints()); for (Point point : holePoints) { LatLng latLng = toLatLng(point); holeLatLngs.add(latLng); if (point.hasZ()) { z = (z == null) ? point.getZ() : Math.max(z, point.getZ()); } } } else { throw new GeoPackageException("Unsupported Curve Hole Type: " + hole.getClass().getSimpleName()); } polygonOptions.addHole(holeLatLngs); } if (curvePolygon.hasZ() && z != null) { polygonOptions.zIndex(z.floatValue()); } } return polygonOptions; } }
public class class_name { public PolygonOptions toCurvePolygon(CurvePolygon curvePolygon) { PolygonOptions polygonOptions = new PolygonOptions(); List<Curve> rings = curvePolygon.getRings(); if (!rings.isEmpty()) { Double z = null; // Add the polygon points Curve curve = rings.get(0); if (curve instanceof CompoundCurve) { CompoundCurve compoundCurve = (CompoundCurve) curve; for (LineString lineString : compoundCurve.getLineStrings()) { // Try to simplify the number of points in the compound curve List<Point> points = simplifyPoints(lineString.getPoints()); for (Point point : points) { LatLng latLng = toLatLng(point); polygonOptions.add(latLng); // depends on control dependency: [for], data = [none] if (point.hasZ()) { z = (z == null) ? point.getZ() : Math.max(z, point.getZ()); // depends on control dependency: [if], data = [none] } } } } else if (curve instanceof LineString) { LineString lineString = (LineString) curve; // Try to simplify the number of points in the curve List<Point> points = simplifyPoints(lineString.getPoints()); for (Point point : points) { LatLng latLng = toLatLng(point); polygonOptions.add(latLng); // depends on control dependency: [for], data = [none] if (point.hasZ()) { z = (z == null) ? point.getZ() : Math.max(z, point.getZ()); // depends on control dependency: [if], data = [none] } } } else { throw new GeoPackageException("Unsupported Curve Type: " + curve.getClass().getSimpleName()); } // Add the holes for (int i = 1; i < rings.size(); i++) { Curve hole = rings.get(i); List<LatLng> holeLatLngs = new ArrayList<LatLng>(); if (hole instanceof CompoundCurve) { CompoundCurve holeCompoundCurve = (CompoundCurve) hole; for (LineString holeLineString : holeCompoundCurve.getLineStrings()) { // Try to simplify the number of points in the hole List<Point> holePoints = simplifyPoints(holeLineString.getPoints()); for (Point point : holePoints) { LatLng latLng = toLatLng(point); holeLatLngs.add(latLng); // depends on control dependency: [for], data = [none] if (point.hasZ()) { z = (z == null) ? point.getZ() : Math.max(z, point.getZ()); // depends on control dependency: [if], data = [none] } } } } else if (hole instanceof LineString) { LineString holeLineString = (LineString) hole; // Try to simplify the number of points in the hole List<Point> holePoints = simplifyPoints(holeLineString.getPoints()); for (Point point : holePoints) { LatLng latLng = toLatLng(point); holeLatLngs.add(latLng); // depends on control dependency: [for], data = [none] if (point.hasZ()) { z = (z == null) ? point.getZ() : Math.max(z, point.getZ()); // depends on control dependency: [if], data = [none] } } } else { throw new GeoPackageException("Unsupported Curve Hole Type: " + hole.getClass().getSimpleName()); } polygonOptions.addHole(holeLatLngs); // depends on control dependency: [for], data = [none] } if (curvePolygon.hasZ() && z != null) { polygonOptions.zIndex(z.floatValue()); // depends on control dependency: [if], data = [none] } } return polygonOptions; } }
public class class_name { @Override public List<ApplicationTemplate> listApplicationTemplates( String exactName, String exactQualifier, String tag ) { // Log if( this.logger.isLoggable( Level.FINE )) { if( exactName == null && exactQualifier == null ) { this.logger.fine( "Request: list all the application templates." ); } else { StringBuilder sb = new StringBuilder( "Request: list/find the application templates" ); if( exactName != null ) { sb.append( " with name = " ); sb.append( exactName ); } if( exactQualifier != null ) { if( exactName != null ) sb.append( " and" ); sb.append( " qualifier = " ); sb.append( exactQualifier ); } sb.append( "." ); this.logger.fine( sb.toString()); } } // Search List<ApplicationTemplate> result = new ArrayList<> (); for( ApplicationTemplate tpl : this.manager.applicationTemplateMngr().getApplicationTemplates()) { // Equality is on the name, not on the display name if(( exactName == null || exactName.equals( tpl.getName())) && (exactQualifier == null || exactQualifier.equals( tpl.getVersion()) && (tag == null || tpl.getTags().contains( tag )))) result.add( tpl ); } return result; } }
public class class_name { @Override public List<ApplicationTemplate> listApplicationTemplates( String exactName, String exactQualifier, String tag ) { // Log if( this.logger.isLoggable( Level.FINE )) { if( exactName == null && exactQualifier == null ) { this.logger.fine( "Request: list all the application templates." ); // depends on control dependency: [if], data = [none] } else { StringBuilder sb = new StringBuilder( "Request: list/find the application templates" ); if( exactName != null ) { sb.append( " with name = " ); // depends on control dependency: [if], data = [none] sb.append( exactName ); // depends on control dependency: [if], data = [( exactName] } if( exactQualifier != null ) { if( exactName != null ) sb.append( " and" ); sb.append( " qualifier = " ); // depends on control dependency: [if], data = [none] sb.append( exactQualifier ); // depends on control dependency: [if], data = [( exactQualifier] } sb.append( "." ); // depends on control dependency: [if], data = [none] this.logger.fine( sb.toString()); // depends on control dependency: [if], data = [none] } } // Search List<ApplicationTemplate> result = new ArrayList<> (); for( ApplicationTemplate tpl : this.manager.applicationTemplateMngr().getApplicationTemplates()) { // Equality is on the name, not on the display name if(( exactName == null || exactName.equals( tpl.getName())) && (exactQualifier == null || exactQualifier.equals( tpl.getVersion()) && (tag == null || tpl.getTags().contains( tag )))) result.add( tpl ); } return result; } }
public class class_name { @VisibleForTesting Config updateNumContainersIfNeeded(Config initialConfig, TopologyAPI.Topology initialTopology, PackingPlan packingPlan) { int configNumStreamManagers = TopologyUtils.getNumContainers(initialTopology); int packingNumStreamManagers = packingPlan.getContainers().size(); if (configNumStreamManagers == packingNumStreamManagers) { return initialConfig; } Config.Builder newConfigBuilder = Config.newBuilder() .putAll(initialConfig) .put(Key.NUM_CONTAINERS, packingNumStreamManagers + 1) .put(Key.TOPOLOGY_DEFINITION, cloneWithNewNumContainers(initialTopology, packingNumStreamManagers)); String packingClass = Context.packingClass(config); LOG.warning(String.format("The packing plan (generated by %s) calls for a different number of " + "containers (%d) than what was explicitly set in the topology configs (%d). " + "Overriding the configs to specify %d containers. When using %s do not explicitly " + "call config.setNumStmgrs(..) or config.setNumWorkers(..).", packingClass, packingNumStreamManagers, configNumStreamManagers, packingNumStreamManagers, packingClass)); return newConfigBuilder.build(); } }
public class class_name { @VisibleForTesting Config updateNumContainersIfNeeded(Config initialConfig, TopologyAPI.Topology initialTopology, PackingPlan packingPlan) { int configNumStreamManagers = TopologyUtils.getNumContainers(initialTopology); int packingNumStreamManagers = packingPlan.getContainers().size(); if (configNumStreamManagers == packingNumStreamManagers) { return initialConfig; // depends on control dependency: [if], data = [none] } Config.Builder newConfigBuilder = Config.newBuilder() .putAll(initialConfig) .put(Key.NUM_CONTAINERS, packingNumStreamManagers + 1) .put(Key.TOPOLOGY_DEFINITION, cloneWithNewNumContainers(initialTopology, packingNumStreamManagers)); String packingClass = Context.packingClass(config); LOG.warning(String.format("The packing plan (generated by %s) calls for a different number of " + "containers (%d) than what was explicitly set in the topology configs (%d). " + "Overriding the configs to specify %d containers. When using %s do not explicitly " + "call config.setNumStmgrs(..) or config.setNumWorkers(..).", packingClass, packingNumStreamManagers, configNumStreamManagers, packingNumStreamManagers, packingClass)); return newConfigBuilder.build(); } }