code
stringlengths
130
281k
code_dependency
stringlengths
182
306k
public class class_name { private static final LockFile newNIOLockFile() { if (NIO_FILELOCK_AVAILABLE && NIO_LOCKFILE_CLASS != null) { try { return (LockFile) NIO_LOCKFILE_CLASS.newInstance(); } catch (Exception e) { // e.printStackTrace() } } return null; } }
public class class_name { private static final LockFile newNIOLockFile() { if (NIO_FILELOCK_AVAILABLE && NIO_LOCKFILE_CLASS != null) { try { return (LockFile) NIO_LOCKFILE_CLASS.newInstance(); // depends on control dependency: [try], data = [none] } catch (Exception e) { // e.printStackTrace() } // depends on control dependency: [catch], data = [none] } return null; } }
public class class_name { @FFDCIgnore({ NumberFormatException.class, ArithmeticException.class, ConfigEvaluatorException.class }) private String tryEvaluateExpression(String expr, final EvaluationContext context, final boolean ignoreWarnings) { try { return new ConfigExpressionEvaluator() { @Override String getProperty(String argName) throws ConfigEvaluatorException { return VariableEvaluator.this.getProperty(argName, context, ignoreWarnings, false); } @Override Object getPropertyObject(String argName) throws ConfigEvaluatorException { return VariableEvaluator.this.getPropertyObject(argName, context, ignoreWarnings, false); } }.evaluateExpression(expr); } catch (NumberFormatException e) { // ${0+string}, or a number that exceeds MAX_LONG. } catch (ArithmeticException e) { // ${x/0} } catch (ConfigEvaluatorException e) { // If getPropertyObject fails } return null; } }
public class class_name { @FFDCIgnore({ NumberFormatException.class, ArithmeticException.class, ConfigEvaluatorException.class }) private String tryEvaluateExpression(String expr, final EvaluationContext context, final boolean ignoreWarnings) { try { return new ConfigExpressionEvaluator() { @Override String getProperty(String argName) throws ConfigEvaluatorException { return VariableEvaluator.this.getProperty(argName, context, ignoreWarnings, false); } // depends on control dependency: [try], data = [none] @Override Object getPropertyObject(String argName) throws ConfigEvaluatorException { return VariableEvaluator.this.getPropertyObject(argName, context, ignoreWarnings, false); // depends on control dependency: [try], data = [none] } }.evaluateExpression(expr); } catch (NumberFormatException e) { // ${0+string}, or a number that exceeds MAX_LONG. } catch (ArithmeticException e) { // depends on control dependency: [catch], data = [none] // ${x/0} } catch (ConfigEvaluatorException e) { // depends on control dependency: [catch], data = [none] // If getPropertyObject fails } // depends on control dependency: [catch], data = [none] return null; } }
public class class_name { @Override public EClass getIfcMaterialProfileSet() { if (ifcMaterialProfileSetEClass == null) { ifcMaterialProfileSetEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI) .getEClassifiers().get(368); } return ifcMaterialProfileSetEClass; } }
public class class_name { @Override public EClass getIfcMaterialProfileSet() { if (ifcMaterialProfileSetEClass == null) { ifcMaterialProfileSetEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI) .getEClassifiers().get(368); // depends on control dependency: [if], data = [none] } return ifcMaterialProfileSetEClass; } }
public class class_name { public Properties getPropertiesFromDynamicSelectionInfo(Map<String, Object> connectionInfo) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.entry(tc, "getPropertiesFromDynamicSelectionInfo", new Object[] { connectionInfo }); if (connectionInfo == null) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "No connection information provided."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo"); return null; // this allows it to move forward with other precedence. } if (dynamicSelections.isEmpty()) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "There are no dynamic outbound selections configured."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo"); return null; } /*** * First look for a cached MISS in case it has already been looked * up from this particular connection info data. ***/ synchronized (dynamicLookupMisses) { if (dynamicLookupMisses.contains(connectionInfo)) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "This connectionInfo was checked before, found in the lookup misses cache."); if (tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo"); return null; } } /*** * Next look for a cache HIT in case it has already been looked up from this * particular connection info data. ***/ if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "Dynamic outbound lookup cache size is " + dynamicLookupCache.size()); SSLConfig cachedConfig = dynamicLookupCache.get(connectionInfo); if (cachedConfig != null) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "Found in cache."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo", cachedConfig); return cachedConfig; } String direction = (String) connectionInfo.get(Constants.CONNECTION_INFO_DIRECTION); if (direction != null && direction.equals(Constants.DIRECTION_INBOUND)) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "Connection information is for an inbound connection return null."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo"); return null; } String connInfoRemoteHost = (String) connectionInfo.get(Constants.CONNECTION_INFO_REMOTE_HOST); String connInfoRemotePort = (String) connectionInfo.get(Constants.CONNECTION_INFO_REMOTE_PORT); Tr.debug(tc, "Host from connectionInfo is " + connInfoRemoteHost + " and port from connectionInfo is " + connInfoRemotePort); /*** * Look through all of the SSLConfigs in this list which all contain a * property with values for com.ibm.ssl.dynamicSelectionInfo. ***/ if (connInfoRemoteHost != null) { SSLConfig sslCfg = lookForMatchInList(dynamicHostPortSelections, connInfoRemoteHost, connInfoRemotePort); if (sslCfg != null) { dynamicLookupCache.put(connectionInfo, sslCfg); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "Found in the host and port list."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo", sslCfg); return sslCfg; } sslCfg = lookForMatchInList(dynamicHostSelections, connInfoRemoteHost, connInfoRemotePort); if (sslCfg != null) { dynamicLookupCache.put(connectionInfo, sslCfg); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "Found in the host list."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo", sslCfg); return sslCfg; } } synchronized (dynamicLookupMisses) { if (dynamicLookupMisses.size() > 50) { if (tc.isDebugEnabled()) Tr.debug(tc, "Cache miss tree set size is > 50, clearing the TreeSet."); dynamicLookupMisses.clear(); } dynamicLookupMisses.add(connectionInfo); if (tc.isDebugEnabled()) Tr.debug(tc, "Cache miss tree set size is " + dynamicLookupMisses.size() + " entries."); } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "No match found in host or host and port list."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo"); return null; } }
public class class_name { public Properties getPropertiesFromDynamicSelectionInfo(Map<String, Object> connectionInfo) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.entry(tc, "getPropertiesFromDynamicSelectionInfo", new Object[] { connectionInfo }); if (connectionInfo == null) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "No connection information provided."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo"); return null; // this allows it to move forward with other precedence. // depends on control dependency: [if], data = [none] } if (dynamicSelections.isEmpty()) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "There are no dynamic outbound selections configured."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo"); return null; // depends on control dependency: [if], data = [none] } /*** * First look for a cached MISS in case it has already been looked * up from this particular connection info data. ***/ synchronized (dynamicLookupMisses) { if (dynamicLookupMisses.contains(connectionInfo)) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "This connectionInfo was checked before, found in the lookup misses cache."); if (tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo"); return null; // depends on control dependency: [if], data = [none] } } /*** * Next look for a cache HIT in case it has already been looked up from this * particular connection info data. ***/ if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "Dynamic outbound lookup cache size is " + dynamicLookupCache.size()); SSLConfig cachedConfig = dynamicLookupCache.get(connectionInfo); if (cachedConfig != null) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "Found in cache."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo", cachedConfig); return cachedConfig; // depends on control dependency: [if], data = [none] } String direction = (String) connectionInfo.get(Constants.CONNECTION_INFO_DIRECTION); if (direction != null && direction.equals(Constants.DIRECTION_INBOUND)) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "Connection information is for an inbound connection return null."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo"); return null; // depends on control dependency: [if], data = [none] } String connInfoRemoteHost = (String) connectionInfo.get(Constants.CONNECTION_INFO_REMOTE_HOST); String connInfoRemotePort = (String) connectionInfo.get(Constants.CONNECTION_INFO_REMOTE_PORT); Tr.debug(tc, "Host from connectionInfo is " + connInfoRemoteHost + " and port from connectionInfo is " + connInfoRemotePort); /*** * Look through all of the SSLConfigs in this list which all contain a * property with values for com.ibm.ssl.dynamicSelectionInfo. ***/ if (connInfoRemoteHost != null) { SSLConfig sslCfg = lookForMatchInList(dynamicHostPortSelections, connInfoRemoteHost, connInfoRemotePort); if (sslCfg != null) { dynamicLookupCache.put(connectionInfo, sslCfg); // depends on control dependency: [if], data = [none] if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "Found in the host and port list."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo", sslCfg); return sslCfg; // depends on control dependency: [if], data = [none] } sslCfg = lookForMatchInList(dynamicHostSelections, connInfoRemoteHost, connInfoRemotePort); // depends on control dependency: [if], data = [none] if (sslCfg != null) { dynamicLookupCache.put(connectionInfo, sslCfg); // depends on control dependency: [if], data = [none] if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "Found in the host list."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo", sslCfg); return sslCfg; // depends on control dependency: [if], data = [none] } } synchronized (dynamicLookupMisses) { if (dynamicLookupMisses.size() > 50) { if (tc.isDebugEnabled()) Tr.debug(tc, "Cache miss tree set size is > 50, clearing the TreeSet."); dynamicLookupMisses.clear(); // depends on control dependency: [if], data = [none] } dynamicLookupMisses.add(connectionInfo); if (tc.isDebugEnabled()) Tr.debug(tc, "Cache miss tree set size is " + dynamicLookupMisses.size() + " entries."); } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "No match found in host or host and port list."); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) Tr.exit(tc, "getPropertiesFromDynamicSelectionInfo"); return null; } }
public class class_name { public void insertNewRow() { // reset all fields for (int i = 0; i < komponente.length; i++) { komponente[i].clearContent(); } // end of for (int i=0; i<komponente.length; i++) // reset the field for the primary keys for (int i = 0; i < primaryKeys.length; i++) { komponente[pkColIndex[i]].setEditable(true); } ZaurusEditor.printStatus("enter a new row for table " + tableName); } }
public class class_name { public void insertNewRow() { // reset all fields for (int i = 0; i < komponente.length; i++) { komponente[i].clearContent(); // depends on control dependency: [for], data = [i] } // end of for (int i=0; i<komponente.length; i++) // reset the field for the primary keys for (int i = 0; i < primaryKeys.length; i++) { komponente[pkColIndex[i]].setEditable(true); // depends on control dependency: [for], data = [i] } ZaurusEditor.printStatus("enter a new row for table " + tableName); } }
public class class_name { static String8 createPathNameLocked(final asset_path ap, final String rootDir) { String8 path = new String8(ap.path); if (rootDir != null) { path.appendPath(rootDir); } return path; } }
public class class_name { static String8 createPathNameLocked(final asset_path ap, final String rootDir) { String8 path = new String8(ap.path); if (rootDir != null) { path.appendPath(rootDir); // depends on control dependency: [if], data = [(rootDir] } return path; } }
public class class_name { public static Integer[] box (int[] list) { if (list == null) { return null; } Integer[] boxed = new Integer[list.length]; for (int ii = 0; ii < list.length; ii++) { boxed[ii] = list[ii]; } return boxed; } }
public class class_name { public static Integer[] box (int[] list) { if (list == null) { return null; // depends on control dependency: [if], data = [none] } Integer[] boxed = new Integer[list.length]; for (int ii = 0; ii < list.length; ii++) { boxed[ii] = list[ii]; // depends on control dependency: [for], data = [ii] } return boxed; } }
public class class_name { public DTMAxisTraverser getAxisTraverser(final int axis) { DTMAxisTraverser traverser; if (null == m_traversers) // Cache of stateless traversers for this DTM { m_traversers = new DTMAxisTraverser[Axis.getNamesLength()]; traverser = null; } else { traverser = m_traversers[axis]; // Share/reuse existing traverser if (traverser != null) return traverser; } switch (axis) // Generate new traverser { case Axis.ANCESTOR : traverser = new AncestorTraverser(); break; case Axis.ANCESTORORSELF : traverser = new AncestorOrSelfTraverser(); break; case Axis.ATTRIBUTE : traverser = new AttributeTraverser(); break; case Axis.CHILD : traverser = new ChildTraverser(); break; case Axis.DESCENDANT : traverser = new DescendantTraverser(); break; case Axis.DESCENDANTORSELF : traverser = new DescendantOrSelfTraverser(); break; case Axis.FOLLOWING : traverser = new FollowingTraverser(); break; case Axis.FOLLOWINGSIBLING : traverser = new FollowingSiblingTraverser(); break; case Axis.NAMESPACE : traverser = new NamespaceTraverser(); break; case Axis.NAMESPACEDECLS : traverser = new NamespaceDeclsTraverser(); break; case Axis.PARENT : traverser = new ParentTraverser(); break; case Axis.PRECEDING : traverser = new PrecedingTraverser(); break; case Axis.PRECEDINGSIBLING : traverser = new PrecedingSiblingTraverser(); break; case Axis.SELF : traverser = new SelfTraverser(); break; case Axis.ALL : traverser = new AllFromRootTraverser(); break; case Axis.ALLFROMNODE : traverser = new AllFromNodeTraverser(); break; case Axis.PRECEDINGANDANCESTOR : traverser = new PrecedingAndAncestorTraverser(); break; case Axis.DESCENDANTSFROMROOT : traverser = new DescendantFromRootTraverser(); break; case Axis.DESCENDANTSORSELFFROMROOT : traverser = new DescendantOrSelfFromRootTraverser(); break; case Axis.ROOT : traverser = new RootTraverser(); break; case Axis.FILTEREDLIST : return null; // Don't want to throw an exception for this one. default : throw new DTMException(XMLMessages.createXMLMessage(XMLErrorResources.ER_UNKNOWN_AXIS_TYPE, new Object[]{Integer.toString(axis)})); //"Unknown axis traversal type: "+axis); } if (null == traverser) throw new DTMException(XMLMessages.createXMLMessage(XMLErrorResources.ER_AXIS_TRAVERSER_NOT_SUPPORTED, new Object[]{Axis.getNames(axis)})); // "Axis traverser not supported: " // + Axis.names[axis]); m_traversers[axis] = traverser; return traverser; } }
public class class_name { public DTMAxisTraverser getAxisTraverser(final int axis) { DTMAxisTraverser traverser; if (null == m_traversers) // Cache of stateless traversers for this DTM { m_traversers = new DTMAxisTraverser[Axis.getNamesLength()]; // depends on control dependency: [if], data = [none] traverser = null; // depends on control dependency: [if], data = [none] } else { traverser = m_traversers[axis]; // Share/reuse existing traverser // depends on control dependency: [if], data = [none] if (traverser != null) return traverser; } switch (axis) // Generate new traverser { case Axis.ANCESTOR : traverser = new AncestorTraverser(); break; case Axis.ANCESTORORSELF : traverser = new AncestorOrSelfTraverser(); break; case Axis.ATTRIBUTE : traverser = new AttributeTraverser(); break; case Axis.CHILD : traverser = new ChildTraverser(); break; case Axis.DESCENDANT : traverser = new DescendantTraverser(); break; case Axis.DESCENDANTORSELF : traverser = new DescendantOrSelfTraverser(); break; case Axis.FOLLOWING : traverser = new FollowingTraverser(); break; case Axis.FOLLOWINGSIBLING : traverser = new FollowingSiblingTraverser(); break; case Axis.NAMESPACE : traverser = new NamespaceTraverser(); break; case Axis.NAMESPACEDECLS : traverser = new NamespaceDeclsTraverser(); break; case Axis.PARENT : traverser = new ParentTraverser(); break; case Axis.PRECEDING : traverser = new PrecedingTraverser(); break; case Axis.PRECEDINGSIBLING : traverser = new PrecedingSiblingTraverser(); break; case Axis.SELF : traverser = new SelfTraverser(); break; case Axis.ALL : traverser = new AllFromRootTraverser(); break; case Axis.ALLFROMNODE : traverser = new AllFromNodeTraverser(); break; case Axis.PRECEDINGANDANCESTOR : traverser = new PrecedingAndAncestorTraverser(); break; case Axis.DESCENDANTSFROMROOT : traverser = new DescendantFromRootTraverser(); break; case Axis.DESCENDANTSORSELFFROMROOT : traverser = new DescendantOrSelfFromRootTraverser(); break; case Axis.ROOT : traverser = new RootTraverser(); break; case Axis.FILTEREDLIST : return null; // Don't want to throw an exception for this one. default : throw new DTMException(XMLMessages.createXMLMessage(XMLErrorResources.ER_UNKNOWN_AXIS_TYPE, new Object[]{Integer.toString(axis)})); //"Unknown axis traversal type: "+axis); } if (null == traverser) throw new DTMException(XMLMessages.createXMLMessage(XMLErrorResources.ER_AXIS_TRAVERSER_NOT_SUPPORTED, new Object[]{Axis.getNames(axis)})); // "Axis traverser not supported: " // + Axis.names[axis]); m_traversers[axis] = traverser; return traverser; } }
public class class_name { List<Contig> getShards(long numberOfBasesPerShard) { double shardCount = (end - start) / (double) numberOfBasesPerShard; List<Contig> shards = Lists.newArrayList(); for (int i = 0; i < shardCount; i++) { long shardStart = start + (i * numberOfBasesPerShard); long shardEnd = Math.min(end, shardStart + numberOfBasesPerShard); shards.add(new Contig(referenceName, shardStart, shardEnd)); } return shards; } }
public class class_name { List<Contig> getShards(long numberOfBasesPerShard) { double shardCount = (end - start) / (double) numberOfBasesPerShard; List<Contig> shards = Lists.newArrayList(); for (int i = 0; i < shardCount; i++) { long shardStart = start + (i * numberOfBasesPerShard); long shardEnd = Math.min(end, shardStart + numberOfBasesPerShard); shards.add(new Contig(referenceName, shardStart, shardEnd)); // depends on control dependency: [for], data = [none] } return shards; } }
public class class_name { public static void shutdownAndAwaitTermination(ExecutorService pool, long timeToWait4ShutDown, long timeToWait4ShutDownNow) { synchronized (pool) { // Disable new tasks from being submitted pool.shutdown(); } try { // Wait a while for existing tasks to terminate if (!pool.awaitTermination(timeToWait4ShutDown, TimeUnit.SECONDS)) { synchronized (pool) { pool.shutdownNow(); // Cancel currently executing tasks } // Wait a while for tasks to respond to being cancelled if (!pool.awaitTermination(timeToWait4ShutDownNow, TimeUnit.SECONDS)) { Log.e(Log.TAG_DATABASE, "Pool did not terminate"); } } } catch (InterruptedException ie) { // (Re-)Cancel if current thread also interrupted synchronized (pool) { pool.shutdownNow(); } // Preserve interrupt status Thread.currentThread().interrupt(); } } }
public class class_name { public static void shutdownAndAwaitTermination(ExecutorService pool, long timeToWait4ShutDown, long timeToWait4ShutDownNow) { synchronized (pool) { // Disable new tasks from being submitted pool.shutdown(); } try { // Wait a while for existing tasks to terminate if (!pool.awaitTermination(timeToWait4ShutDown, TimeUnit.SECONDS)) { synchronized (pool) { // depends on control dependency: [if], data = [none] pool.shutdownNow(); // Cancel currently executing tasks } // Wait a while for tasks to respond to being cancelled if (!pool.awaitTermination(timeToWait4ShutDownNow, TimeUnit.SECONDS)) { Log.e(Log.TAG_DATABASE, "Pool did not terminate"); // depends on control dependency: [if], data = [none] } } } catch (InterruptedException ie) { // (Re-)Cancel if current thread also interrupted synchronized (pool) { pool.shutdownNow(); } // Preserve interrupt status Thread.currentThread().interrupt(); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public final <T extends View> T getFreshestView(ArrayList<T> views){ final int[] locationOnScreen = new int[2]; T viewToReturn = null; long drawingTime = 0; if(views == null){ return null; } for(T view : views){ if(view != null){ view.getLocationOnScreen(locationOnScreen); if (locationOnScreen[0] < 0 || !(view.getHeight() > 0)){ continue; } if(view.getDrawingTime() > drawingTime){ drawingTime = view.getDrawingTime(); viewToReturn = view; } else if (view.getDrawingTime() == drawingTime){ if(view.isFocused()){ viewToReturn = view; } } } } views = null; return viewToReturn; } }
public class class_name { public final <T extends View> T getFreshestView(ArrayList<T> views){ final int[] locationOnScreen = new int[2]; T viewToReturn = null; long drawingTime = 0; if(views == null){ return null; // depends on control dependency: [if], data = [none] } for(T view : views){ if(view != null){ view.getLocationOnScreen(locationOnScreen); // depends on control dependency: [if], data = [none] if (locationOnScreen[0] < 0 || !(view.getHeight() > 0)){ continue; } if(view.getDrawingTime() > drawingTime){ drawingTime = view.getDrawingTime(); // depends on control dependency: [if], data = [none] viewToReturn = view; // depends on control dependency: [if], data = [none] } else if (view.getDrawingTime() == drawingTime){ if(view.isFocused()){ viewToReturn = view; // depends on control dependency: [if], data = [none] } } } } views = null; return viewToReturn; } }
public class class_name { private void deleteRow(String storeName, String rowKey) { List<String> rowKeys = m_rowDeletes.get(storeName); if (rowKeys == null) { rowKeys = new ArrayList<>(); m_rowDeletes.put(storeName, rowKeys); } rowKeys.add(rowKey); m_totalUpdates++; } }
public class class_name { private void deleteRow(String storeName, String rowKey) { List<String> rowKeys = m_rowDeletes.get(storeName); if (rowKeys == null) { rowKeys = new ArrayList<>(); // depends on control dependency: [if], data = [none] m_rowDeletes.put(storeName, rowKeys); // depends on control dependency: [if], data = [none] } rowKeys.add(rowKey); m_totalUpdates++; } }
public class class_name { private byte[] shrinkBuffer(byte[] buffer, int size) { if (size == 0) { return null; } if (size == buffer.length) { return buffer; } byte[] output = new byte[size]; System.arraycopy(buffer, 0, output, 0, size); return output; } }
public class class_name { private byte[] shrinkBuffer(byte[] buffer, int size) { if (size == 0) { return null; // depends on control dependency: [if], data = [none] } if (size == buffer.length) { return buffer; // depends on control dependency: [if], data = [none] } byte[] output = new byte[size]; System.arraycopy(buffer, 0, output, 0, size); return output; } }
public class class_name { public static Collection<TimeSlot> calculateTimeSots( Day day, int intervalSeconds, Time startTime, Time endTime) { if(intervalSeconds <1) { throw new IllegalArgumentException("interval seconds cannot be less than one"); } int count = 1*60*60*24/intervalSeconds; ArrayList<TimeSlot> slots = new ArrayList<TimeSlot>(count); TimeSlot startSlot = TimeSlot.firstSlot(day,startTime, intervalSeconds); TimeSlot slot = startSlot; while(slot != null) { slots.add(slot); slot = slot.nextTimeSlot(intervalSeconds,endTime); } return slots; } }
public class class_name { public static Collection<TimeSlot> calculateTimeSots( Day day, int intervalSeconds, Time startTime, Time endTime) { if(intervalSeconds <1) { throw new IllegalArgumentException("interval seconds cannot be less than one"); } int count = 1*60*60*24/intervalSeconds; ArrayList<TimeSlot> slots = new ArrayList<TimeSlot>(count); TimeSlot startSlot = TimeSlot.firstSlot(day,startTime, intervalSeconds); TimeSlot slot = startSlot; while(slot != null) { slots.add(slot); // depends on control dependency: [while], data = [(slot] slot = slot.nextTimeSlot(intervalSeconds,endTime); // depends on control dependency: [while], data = [none] } return slots; } }
public class class_name { private boolean askToSave() { if (mainFrame.isProjectChanged()) { int response = JOptionPane.showConfirmDialog(mainFrame, L10N.getLocalString("dlg.save_current_changes", "The current project has been changed, Save current changes?"), L10N.getLocalString("dlg.save_changes", "Save Changes?"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.YES_OPTION) { if (mainFrame.getSaveFile() != null) { save(); } else { saveAs(); } } else if (response == JOptionPane.CANCEL_OPTION) { return true; // IF no, do nothing. } } return false; } }
public class class_name { private boolean askToSave() { if (mainFrame.isProjectChanged()) { int response = JOptionPane.showConfirmDialog(mainFrame, L10N.getLocalString("dlg.save_current_changes", "The current project has been changed, Save current changes?"), L10N.getLocalString("dlg.save_changes", "Save Changes?"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.YES_OPTION) { if (mainFrame.getSaveFile() != null) { save(); // depends on control dependency: [if], data = [none] } else { saveAs(); // depends on control dependency: [if], data = [none] } } else if (response == JOptionPane.CANCEL_OPTION) { return true; // depends on control dependency: [if], data = [none] // IF no, do nothing. } } return false; } }
public class class_name { protected void checkForBatchError(JsonNode root) { JsonNode errorCode = root.get("error"); if (errorCode != null) { JsonNode errorDescription = root.get("error_description"); if (errorDescription != null) { int code = errorCode.intValue(); String msg = errorDescription.asText(); this.throwCodeAndMessage(code, msg); } } } }
public class class_name { protected void checkForBatchError(JsonNode root) { JsonNode errorCode = root.get("error"); if (errorCode != null) { JsonNode errorDescription = root.get("error_description"); if (errorDescription != null) { int code = errorCode.intValue(); String msg = errorDescription.asText(); this.throwCodeAndMessage(code, msg); // depends on control dependency: [if], data = [none] } } } }
public class class_name { public static final void setValue(Object bean, String property, Object v) { Object vv = BeanHelper.getValue(bean, property); if (v != null && v.getClass().isArray() && vv != null && (vv instanceof Collection)) { // array assignment to Collection Collection col = (Collection) vv; Class[] pt = BeanHelper.getParameterTypes(bean, property); col.clear(); int len = Array.getLength(v); for (int ii=0;ii<len;ii++) { col.add(ConvertUtility.convert(pt[0], Array.get(v, ii))); } } else { if (v != null && v.getClass().isArray()) { // array with single menber if (Array.getLength(v) == 1) { v = Array.get(v, 0); } } Class<?> type = BeanHelper.getType(bean, property); if (v != null) { v = ConvertUtility.convert(type, v); } Object value = v; doFor( bean, property, type, (Object a, int i)->{Array.set(a, i, value);return null;}, (List l, int i)->{l.set(i, value);return null;}, (Object b, Class c, String p)->{try { c.getField(p).set(b, value);return null; } catch (IllegalArgumentException | IllegalAccessException ex) { throw new IllegalArgumentException(ex); } }, (Object b, Method m)->{try { m.invoke(b, value);return null; } catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(ex); } }); } } }
public class class_name { public static final void setValue(Object bean, String property, Object v) { Object vv = BeanHelper.getValue(bean, property); if (v != null && v.getClass().isArray() && vv != null && (vv instanceof Collection)) { // array assignment to Collection Collection col = (Collection) vv; Class[] pt = BeanHelper.getParameterTypes(bean, property); col.clear(); int len = Array.getLength(v); for (int ii=0;ii<len;ii++) { col.add(ConvertUtility.convert(pt[0], Array.get(v, ii))); // depends on control dependency: [for], data = [ii] } } else { if (v != null && v.getClass().isArray()) { // array with single menber if (Array.getLength(v) == 1) { v = Array.get(v, 0); // depends on control dependency: [if], data = [none] } } Class<?> type = BeanHelper.getType(bean, property); if (v != null) { v = ConvertUtility.convert(type, v); // depends on control dependency: [if], data = [none] } Object value = v; doFor( bean, property, type, (Object a, int i)->{Array.set(a, i, value);return null;}, // depends on control dependency: [if], data = [none] // depends on control dependency: [if], data = [none] (List l, int i)->{l.set(i, value);return null;}, (Object b, Class c, String p)->{try { c.getField(p).set(b, value);return null; // depends on control dependency: [try], data = [none] // depends on control dependency: [try], data = [none] } catch (IllegalArgumentException | IllegalAccessException ex) { throw new IllegalArgumentException(ex); } // depends on control dependency: [catch], data = [none] }, (Object b, Method m)->{try { m.invoke(b, value);return null; // depends on control dependency: [try], data = [none] // depends on control dependency: [try], data = [none] } catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalArgumentException(ex); } // depends on control dependency: [catch], data = [none] }); } } }
public class class_name { private void sweep() { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); // d532639.2 if (isTraceOn && isTraceEnabled(false)) Tr.entry(tc.isEntryEnabled() ? tc : tcOOM, ivCache.getName() + ": Sweep (" + ivCache.numSweeps + "," + ivDiscardThreshold + "," + ivSweepInterval + ")" + " - Cache limit exceeded : " + ivCache.getSize() + "/" + ivPreferredMaxSize); int numEvicted = 0; long sweepCount = 0; Element element = null; try { while ((element = (Element) ivElements.nextElemNoEx()) != null) { // Basic operations on basic types are atomic, and we // don't care about out-of-sync reads, so we don't // bother synchronizing access to the LRU flag here if (element.accessedSweep <= ivCache.numSweeps) sweepCount = ivCache.numSweeps - element.accessedSweep; else sweepCount = (Long.MAX_VALUE - element.accessedSweep) + ivCache.numSweeps; // Very simple algorithm, if the element has been around for // more than the discard threshold number of sweep intervals, // we evict it or at least try. if (element.pinned == 0 && sweepCount > ivDiscardThreshold) { if (ivCache.evictObject(element.key)) { numEvicted++; } } } } catch (NoSuchElementException e) { // Enumeration may fail earlier than expected due to // concurrent cache access; this is not an error FFDCFilter.processException(e, CLASS_NAME + ".sweep", "499", this); if (isTraceOn && isTraceEnabled(false)) Tr.exit(tc.isEntryEnabled() ? tc : tcOOM, ivCache.getName() + ": Sweep (" + ivCache.numSweeps + "," + ivDiscardThreshold + "," + ivSweepInterval + ")" + " - Evicted = " + numEvicted + " : " + ivCache.getSize() + " : NoSuchElementException"); return; } finally { //PM11713 // Reset the cached enumaration, so it is just like new. This is // done for performance, so a new enumeration doesn't have to be // created (and discarded) every sweep. d103404.2 // Note: performing the reset AFTER the sweep insures that the // cached enumerator does not hold any resources while not in // use (such as a copy of one of the cache buckets). //d310114 ivElements.reset(); } if (isTraceOn && isTraceEnabled(false)) Tr.exit(tc.isEntryEnabled() ? tc : tcOOM, ivCache.getName() + ": Sweep (" + ivCache.numSweeps + "," + ivDiscardThreshold + "," + ivSweepInterval + ")" + " - Evicted = " + numEvicted + " : " + ivCache.getSize() + "/" + ivPreferredMaxSize); } }
public class class_name { private void sweep() { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); // d532639.2 if (isTraceOn && isTraceEnabled(false)) Tr.entry(tc.isEntryEnabled() ? tc : tcOOM, ivCache.getName() + ": Sweep (" + ivCache.numSweeps + "," + ivDiscardThreshold + "," + ivSweepInterval + ")" + " - Cache limit exceeded : " + ivCache.getSize() + "/" + ivPreferredMaxSize); int numEvicted = 0; long sweepCount = 0; Element element = null; try { while ((element = (Element) ivElements.nextElemNoEx()) != null) { // Basic operations on basic types are atomic, and we // don't care about out-of-sync reads, so we don't // bother synchronizing access to the LRU flag here if (element.accessedSweep <= ivCache.numSweeps) sweepCount = ivCache.numSweeps - element.accessedSweep; else sweepCount = (Long.MAX_VALUE - element.accessedSweep) + ivCache.numSweeps; // Very simple algorithm, if the element has been around for // more than the discard threshold number of sweep intervals, // we evict it or at least try. if (element.pinned == 0 && sweepCount > ivDiscardThreshold) { if (ivCache.evictObject(element.key)) { numEvicted++; // depends on control dependency: [if], data = [none] } } } } catch (NoSuchElementException e) { // Enumeration may fail earlier than expected due to // concurrent cache access; this is not an error FFDCFilter.processException(e, CLASS_NAME + ".sweep", "499", this); if (isTraceOn && isTraceEnabled(false)) Tr.exit(tc.isEntryEnabled() ? tc : tcOOM, ivCache.getName() + ": Sweep (" + ivCache.numSweeps + "," + ivDiscardThreshold + "," + ivSweepInterval + ")" + " - Evicted = " + numEvicted + " : " + ivCache.getSize() + " : NoSuchElementException"); return; } finally { //PM11713 // depends on control dependency: [catch], data = [none] // Reset the cached enumaration, so it is just like new. This is // done for performance, so a new enumeration doesn't have to be // created (and discarded) every sweep. d103404.2 // Note: performing the reset AFTER the sweep insures that the // cached enumerator does not hold any resources while not in // use (such as a copy of one of the cache buckets). //d310114 ivElements.reset(); } if (isTraceOn && isTraceEnabled(false)) Tr.exit(tc.isEntryEnabled() ? tc : tcOOM, ivCache.getName() + ": Sweep (" + ivCache.numSweeps + "," + ivDiscardThreshold + "," + ivSweepInterval + ")" + " - Evicted = " + numEvicted + " : " + ivCache.getSize() + "/" + ivPreferredMaxSize); } }
public class class_name { private int findLeftBrace(char chLeft, int fromIndex) { // 查找出现的左括号。 for (int index = fromIndex; index < length; index++) { char ch = pattern.charAt(index); // 如果出现左括号,返回。 if (ch == chLeft) { return index; } // 如果出现非空白字符,返回 - 1. else if (!Character.isWhitespace(ch)) { return -1; } } // 没有找到匹配的括号。 return -1; } }
public class class_name { private int findLeftBrace(char chLeft, int fromIndex) { // 查找出现的左括号。 for (int index = fromIndex; index < length; index++) { char ch = pattern.charAt(index); // 如果出现左括号,返回。 if (ch == chLeft) { return index; // depends on control dependency: [if], data = [none] } // 如果出现非空白字符,返回 - 1. else if (!Character.isWhitespace(ch)) { return -1; // depends on control dependency: [if], data = [none] } } // 没有找到匹配的括号。 return -1; } }
public class class_name { List<TargetWrapperDescriptor> buildList( List<File> targetDirectories, AbstractApplication app ) { List<TargetWrapperDescriptor> result = new ArrayList<> (); for( File targetDirectory : targetDirectories ) { File associationFile = new File( targetDirectory, TARGETS_ASSOC_FILE ); Properties props = Utils.readPropertiesFileQuietly( associationFile, this.logger ); boolean isDefault = false; if( app != null ) isDefault = props.containsKey( new InstanceContext( app ).toString()); TargetWrapperDescriptor tb = build( targetDirectory ); if( tb != null ) { tb.setDefault( isDefault ); result.add( tb ); } } return result; } }
public class class_name { List<TargetWrapperDescriptor> buildList( List<File> targetDirectories, AbstractApplication app ) { List<TargetWrapperDescriptor> result = new ArrayList<> (); for( File targetDirectory : targetDirectories ) { File associationFile = new File( targetDirectory, TARGETS_ASSOC_FILE ); Properties props = Utils.readPropertiesFileQuietly( associationFile, this.logger ); boolean isDefault = false; if( app != null ) isDefault = props.containsKey( new InstanceContext( app ).toString()); TargetWrapperDescriptor tb = build( targetDirectory ); if( tb != null ) { tb.setDefault( isDefault ); // depends on control dependency: [if], data = [none] result.add( tb ); // depends on control dependency: [if], data = [( tb] } } return result; } }
public class class_name { private void addSettingsToMap(Map<String, ScoreComponentSettings> scoreParamSettingsMap, String widgetType, ScoreComponentSettings scoreComponentSettings) { LOGGER.info("addSettingsToMap with widgetType:" + widgetType + " scoreParamSettings:" + scoreComponentSettings); if (null != scoreComponentSettings) { scoreParamSettingsMap.put(widgetType, scoreComponentSettings); } } }
public class class_name { private void addSettingsToMap(Map<String, ScoreComponentSettings> scoreParamSettingsMap, String widgetType, ScoreComponentSettings scoreComponentSettings) { LOGGER.info("addSettingsToMap with widgetType:" + widgetType + " scoreParamSettings:" + scoreComponentSettings); if (null != scoreComponentSettings) { scoreParamSettingsMap.put(widgetType, scoreComponentSettings); // depends on control dependency: [if], data = [scoreComponentSettings)] } } }
public class class_name { void stop() { stopAsync(); try { // stopperThread is not null for sure // join() does nothing if thread already finished stopperThread.join(); lifecycle.tryToMoveTo(Lifecycle.State.STOPPED); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } exit.exit(0); } }
public class class_name { void stop() { stopAsync(); try { // stopperThread is not null for sure // join() does nothing if thread already finished stopperThread.join(); // depends on control dependency: [try], data = [none] lifecycle.tryToMoveTo(Lifecycle.State.STOPPED); // depends on control dependency: [try], data = [none] } catch (InterruptedException e) { Thread.currentThread().interrupt(); } // depends on control dependency: [catch], data = [none] exit.exit(0); } }
public class class_name { public static <T> List<Settable> getConstructorParameters(Constructor<T> constructor, Class<?> ownerType) { Type[] parameterTypes = constructor.getGenericParameterTypes(); Annotation[][] parameterAnnotations = constructor.getParameterAnnotations(); List<Settable> params = Lists.newArrayList(); for (int i = 0; i < parameterTypes.length; i++) { Parameter parameterWrap = new Parameter(parameterTypes[i], i, parameterAnnotations[i]); Settable settable = SettableParameter.from(ownerType, parameterWrap); params.add(settable); } return params; } }
public class class_name { public static <T> List<Settable> getConstructorParameters(Constructor<T> constructor, Class<?> ownerType) { Type[] parameterTypes = constructor.getGenericParameterTypes(); Annotation[][] parameterAnnotations = constructor.getParameterAnnotations(); List<Settable> params = Lists.newArrayList(); for (int i = 0; i < parameterTypes.length; i++) { Parameter parameterWrap = new Parameter(parameterTypes[i], i, parameterAnnotations[i]); Settable settable = SettableParameter.from(ownerType, parameterWrap); params.add(settable); // depends on control dependency: [for], data = [none] } return params; } }
public class class_name { public void marshall(RegisterInstanceRequest registerInstanceRequest, ProtocolMarshaller protocolMarshaller) { if (registerInstanceRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(registerInstanceRequest.getServiceId(), SERVICEID_BINDING); protocolMarshaller.marshall(registerInstanceRequest.getInstanceId(), INSTANCEID_BINDING); protocolMarshaller.marshall(registerInstanceRequest.getCreatorRequestId(), CREATORREQUESTID_BINDING); protocolMarshaller.marshall(registerInstanceRequest.getAttributes(), ATTRIBUTES_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } } }
public class class_name { public void marshall(RegisterInstanceRequest registerInstanceRequest, ProtocolMarshaller protocolMarshaller) { if (registerInstanceRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(registerInstanceRequest.getServiceId(), SERVICEID_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(registerInstanceRequest.getInstanceId(), INSTANCEID_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(registerInstanceRequest.getCreatorRequestId(), CREATORREQUESTID_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(registerInstanceRequest.getAttributes(), ATTRIBUTES_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<DummyItem> loadXmlFromNetwork(String urlString) throws IOException { String jString; // Instantiate the parser List<Entry> entries = null; List<DummyItem> rtnArray = new ArrayList<DummyItem>(); BufferedReader streamReader = null; try { streamReader = new BufferedReader(downloadUrl(urlString)); StringBuilder responseStrBuilder = new StringBuilder(); String inputStr; while ((inputStr = streamReader.readLine()) != null) responseStrBuilder.append(inputStr); jString = responseStrBuilder.toString(); if (jString == null) { Log.e(SamplesApplication.TAG, "Nominatim Webpage: request failed for " + urlString); return new ArrayList<DummyItem>(0); } JSONArray jPlaceIds = new JSONArray(jString); int n = jPlaceIds.length(); entries = new ArrayList<Entry>(n); for (int i = 0; i < n; i++) { JSONObject jPlace = jPlaceIds.getJSONObject(i); Entry poi = new Entry( jPlace.optLong("place_id"), jPlace.getString("osm_type"), jPlace.getString("osm_id"), // jPlace.getString("place_rank"), jPlace.getString("boundingbox"), jPlace.getString("lat"), jPlace.getString("lon"), jPlace.getString("display_name"), jPlace.getString("class"), jPlace.getString("type"), jPlace.getString("importance")); entries.add(poi); } } catch (JSONException e) { e.printStackTrace(); return null; } finally { if (streamReader != null) { streamReader.close(); } } // StackOverflowXmlParser returns a List (called "entries") of Entry objects. // Each Entry object represents a single place in the XML searchresult. // This section processes the entries list to create a 'DummyItem' from each entry. for (Entry entry : entries) { rtnArray.add( new DummyItem(entry.mOsm_id, entry.mDisplay_name.split(",")[0], new LatLong(Double.parseDouble(entry.mLat), Double.parseDouble(entry.mLon)), entry.mDisplay_name)); } return rtnArray; } }
public class class_name { private List<DummyItem> loadXmlFromNetwork(String urlString) throws IOException { String jString; // Instantiate the parser List<Entry> entries = null; List<DummyItem> rtnArray = new ArrayList<DummyItem>(); BufferedReader streamReader = null; try { streamReader = new BufferedReader(downloadUrl(urlString)); StringBuilder responseStrBuilder = new StringBuilder(); String inputStr; while ((inputStr = streamReader.readLine()) != null) responseStrBuilder.append(inputStr); jString = responseStrBuilder.toString(); if (jString == null) { Log.e(SamplesApplication.TAG, "Nominatim Webpage: request failed for " + urlString); // depends on control dependency: [if], data = [none] return new ArrayList<DummyItem>(0); // depends on control dependency: [if], data = [none] } JSONArray jPlaceIds = new JSONArray(jString); int n = jPlaceIds.length(); entries = new ArrayList<Entry>(n); for (int i = 0; i < n; i++) { JSONObject jPlace = jPlaceIds.getJSONObject(i); Entry poi = new Entry( jPlace.optLong("place_id"), jPlace.getString("osm_type"), jPlace.getString("osm_id"), // jPlace.getString("place_rank"), jPlace.getString("boundingbox"), jPlace.getString("lat"), jPlace.getString("lon"), jPlace.getString("display_name"), jPlace.getString("class"), jPlace.getString("type"), jPlace.getString("importance")); entries.add(poi); // depends on control dependency: [for], data = [none] } } catch (JSONException e) { e.printStackTrace(); return null; } finally { if (streamReader != null) { streamReader.close(); // depends on control dependency: [if], data = [none] } } // StackOverflowXmlParser returns a List (called "entries") of Entry objects. // Each Entry object represents a single place in the XML searchresult. // This section processes the entries list to create a 'DummyItem' from each entry. for (Entry entry : entries) { rtnArray.add( new DummyItem(entry.mOsm_id, entry.mDisplay_name.split(",")[0], new LatLong(Double.parseDouble(entry.mLat), Double.parseDouble(entry.mLon)), entry.mDisplay_name)); } return rtnArray; } }
public class class_name { @FFDCIgnore(NoSuchMethodException.class) private void setRRSTransactional() { try { ivRRSTransactional = (Boolean) activationSpec.getClass().getMethod("getRRSTransactional").invoke(activationSpec); } catch (NoSuchMethodException x) { ivRRSTransactional = false; } catch (Exception x) { ivRRSTransactional = x == null; // always false - avoid a FindBugs warning by using the value of x in some trivial way } } }
public class class_name { @FFDCIgnore(NoSuchMethodException.class) private void setRRSTransactional() { try { ivRRSTransactional = (Boolean) activationSpec.getClass().getMethod("getRRSTransactional").invoke(activationSpec); // depends on control dependency: [try], data = [none] } catch (NoSuchMethodException x) { ivRRSTransactional = false; } catch (Exception x) { // depends on control dependency: [catch], data = [none] ivRRSTransactional = x == null; // always false - avoid a FindBugs warning by using the value of x in some trivial way } // depends on control dependency: [catch], data = [none] } }
public class class_name { public ListOrganizationPortfolioAccessResult withOrganizationNodes(OrganizationNode... organizationNodes) { if (this.organizationNodes == null) { setOrganizationNodes(new java.util.ArrayList<OrganizationNode>(organizationNodes.length)); } for (OrganizationNode ele : organizationNodes) { this.organizationNodes.add(ele); } return this; } }
public class class_name { public ListOrganizationPortfolioAccessResult withOrganizationNodes(OrganizationNode... organizationNodes) { if (this.organizationNodes == null) { setOrganizationNodes(new java.util.ArrayList<OrganizationNode>(organizationNodes.length)); // depends on control dependency: [if], data = [none] } for (OrganizationNode ele : organizationNodes) { this.organizationNodes.add(ele); // depends on control dependency: [for], data = [ele] } return this; } }
public class class_name { @Override public void update(Transaction xaction, T item, Map<String, Object> state) throws PersistenceException { String newKey = getKeyValue(state, getPrimaryKey()); String oldKey = getKeyValue(item); if( newKey == null || newKey.equals(oldKey) ) { if( newKey == null ) { state.put(getPrimaryKeyField(), getValue(item, getPrimaryKeyField())); } create(xaction, state); } else { remove(xaction, item); create(xaction, state); } getCache().release(item); } }
public class class_name { @Override public void update(Transaction xaction, T item, Map<String, Object> state) throws PersistenceException { String newKey = getKeyValue(state, getPrimaryKey()); String oldKey = getKeyValue(item); if( newKey == null || newKey.equals(oldKey) ) { if( newKey == null ) { state.put(getPrimaryKeyField(), getValue(item, getPrimaryKeyField())); // depends on control dependency: [if], data = [none] } create(xaction, state); } else { remove(xaction, item); create(xaction, state); } getCache().release(item); } }
public class class_name { public void waitForCompletion() { if (futures == null) { return; } for (Future<?> future : futures) { try { future.wait(); } catch (InterruptedException e) { // TODO Should we catch the exception or should we throw it? // Instrumentation will log to ffdc } } } }
public class class_name { public void waitForCompletion() { if (futures == null) { return; // depends on control dependency: [if], data = [none] } for (Future<?> future : futures) { try { future.wait(); // depends on control dependency: [try], data = [none] } catch (InterruptedException e) { // TODO Should we catch the exception or should we throw it? // Instrumentation will log to ffdc } // depends on control dependency: [catch], data = [none] } } }
public class class_name { private static boolean isWhitespace( StringBuilder builder ) { for( int i = 0; i < builder.length(); i++ ) { if( !Character.isWhitespace( builder.charAt( i ) ) ) { return false; } } return true; } }
public class class_name { private static boolean isWhitespace( StringBuilder builder ) { for( int i = 0; i < builder.length(); i++ ) { if( !Character.isWhitespace( builder.charAt( i ) ) ) { return false; // depends on control dependency: [if], data = [none] } } return true; } }
public class class_name { public short getShort(String key) { if (containsKey(key)) { return Short.parseShort(get(key)); } else { throw new IllegalArgumentException("Missing key " + key + "."); } } }
public class class_name { public short getShort(String key) { if (containsKey(key)) { return Short.parseShort(get(key)); // depends on control dependency: [if], data = [none] } else { throw new IllegalArgumentException("Missing key " + key + "."); } } }
public class class_name { private AbstractHelperDialect initDialect(String dialectClass, Properties properties) { AbstractHelperDialect dialect; if (StringUtil.isEmpty(dialectClass)) { throw new PageException("使用 PageHelper 分页插件时,必须设置 helper 属性"); } try { Class sqlDialectClass = resloveDialectClass(dialectClass); if (AbstractHelperDialect.class.isAssignableFrom(sqlDialectClass)) { dialect = (AbstractHelperDialect) sqlDialectClass.newInstance(); } else { throw new PageException("使用 PageHelper 时,方言必须是实现 " + AbstractHelperDialect.class.getCanonicalName() + " 接口的实现类!"); } } catch (Exception e) { throw new PageException("初始化 helper [" + dialectClass + "]时出错:" + e.getMessage(), e); } dialect.setProperties(properties); return dialect; } }
public class class_name { private AbstractHelperDialect initDialect(String dialectClass, Properties properties) { AbstractHelperDialect dialect; if (StringUtil.isEmpty(dialectClass)) { throw new PageException("使用 PageHelper 分页插件时,必须设置 helper 属性"); } try { Class sqlDialectClass = resloveDialectClass(dialectClass); if (AbstractHelperDialect.class.isAssignableFrom(sqlDialectClass)) { dialect = (AbstractHelperDialect) sqlDialectClass.newInstance(); // depends on control dependency: [if], data = [none] } else { throw new PageException("使用 PageHelper 时,方言必须是实现 " + AbstractHelperDialect.class.getCanonicalName() + " 接口的实现类!"); } } catch (Exception e) { throw new PageException("初始化 helper [" + dialectClass + "]时出错:" + e.getMessage(), e); } // depends on control dependency: [catch], data = [none] dialect.setProperties(properties); return dialect; } }
public class class_name { public ScreenFieldView getViewClassForModel(Class<?> screenFieldClass) { while (screenFieldClass != null) { String strModelClassName = screenFieldClass.getName(); String strViewClassName = null; if (ENABLE_CACHE) strViewClassName = m_classCache.getProperty(strModelClassName); // Name in cache? if (strViewClassName == null) strViewClassName = this.getViewClassNameFromModelClassName(strModelClassName); if (strViewClassName != null) { // Great, found the class name. Try to instantiate the class. ScreenFieldView view = (ScreenFieldView)ClassServiceUtility.getClassService().makeObjectFromClassName(strViewClassName); // Ignore class not found if (view != null) { if (ENABLE_CACHE) m_classCache.setProperty(strModelClassName, strViewClassName); // Success - cache the name for later return view; } } screenFieldClass = screenFieldClass.getSuperclass(); } return null; } }
public class class_name { public ScreenFieldView getViewClassForModel(Class<?> screenFieldClass) { while (screenFieldClass != null) { String strModelClassName = screenFieldClass.getName(); String strViewClassName = null; if (ENABLE_CACHE) strViewClassName = m_classCache.getProperty(strModelClassName); // Name in cache? if (strViewClassName == null) strViewClassName = this.getViewClassNameFromModelClassName(strModelClassName); if (strViewClassName != null) { // Great, found the class name. Try to instantiate the class. ScreenFieldView view = (ScreenFieldView)ClassServiceUtility.getClassService().makeObjectFromClassName(strViewClassName); // Ignore class not found if (view != null) { if (ENABLE_CACHE) m_classCache.setProperty(strModelClassName, strViewClassName); // Success - cache the name for later return view; // depends on control dependency: [if], data = [none] } } screenFieldClass = screenFieldClass.getSuperclass(); // depends on control dependency: [while], data = [none] } return null; } }
public class class_name { public MultiLatLng toLatLngs(MultiPoint multiPoint) { MultiLatLng multiLatLng = new MultiLatLng(); for (Point point : multiPoint.getPoints()) { LatLng latLng = toLatLng(point); multiLatLng.add(latLng); } return multiLatLng; } }
public class class_name { public MultiLatLng toLatLngs(MultiPoint multiPoint) { MultiLatLng multiLatLng = new MultiLatLng(); for (Point point : multiPoint.getPoints()) { LatLng latLng = toLatLng(point); multiLatLng.add(latLng); // depends on control dependency: [for], data = [none] } return multiLatLng; } }
public class class_name { @Deprecated @SuppressWarnings("fallthrough") protected void subFormat(StringBuffer buf, char ch, int count, int beginOffset, int fieldNum, DisplayContext capitalizationContext, FieldPosition pos, Calendar cal) { final int maxIntCount = Integer.MAX_VALUE; final int bufstart = buf.length(); TimeZone tz = cal.getTimeZone(); long date = cal.getTimeInMillis(); String result = null; int patternCharIndex = getIndexFromChar(ch); if (patternCharIndex == -1) { if (ch == 'l') { // (SMALL LETTER L) deprecated placeholder for leap month marker, ignore return; } else { throw new IllegalArgumentException("Illegal pattern character " + "'" + ch + "' in \"" + pattern + '"'); } } final int field = PATTERN_INDEX_TO_CALENDAR_FIELD[patternCharIndex]; int value = 0; // Don't get value unless it is useful if (field >= 0) { value = (patternCharIndex != DateFormat.RELATED_YEAR)? cal.get(field): cal.getRelatedYear(); } NumberFormat currentNumberFormat = getNumberFormat(ch); DateFormatSymbols.CapitalizationContextUsage capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.OTHER; switch (patternCharIndex) { case 0: // 'G' - ERA if ( cal.getType().equals("chinese") || cal.getType().equals("dangi") ) { // moved from ChineseDateFormat zeroPaddingNumber(currentNumberFormat, buf, value, 1, 9); } else { if (count == 5) { safeAppend(formatData.narrowEras, value, buf); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.ERA_NARROW; } else if (count == 4) { safeAppend(formatData.eraNames, value, buf); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.ERA_WIDE; } else { safeAppend(formatData.eras, value, buf); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.ERA_ABBREV; } } break; case 30: // 'U' - YEAR_NAME_FIELD if (formatData.shortYearNames != null && value <= formatData.shortYearNames.length) { safeAppend(formatData.shortYearNames, value-1, buf); break; } // else fall through to numeric year handling, do not break here case 1: // 'y' - YEAR case 18: // 'Y' - YEAR_WOY if ( override != null && (override.compareTo("hebr") == 0 || override.indexOf("y=hebr") >= 0) && value > HEBREW_CAL_CUR_MILLENIUM_START_YEAR && value < HEBREW_CAL_CUR_MILLENIUM_END_YEAR ) { value -= HEBREW_CAL_CUR_MILLENIUM_START_YEAR; } /* According to the specification, if the number of pattern letters ('y') is 2, * the year is truncated to 2 digits; otherwise it is interpreted as a number. * But the original code process 'y', 'yy', 'yyy' in the same way. and process * patterns with 4 or more than 4 'y' characters in the same way. * So I change the codes to meet the specification. [Richard/GCl] */ if (count == 2) { zeroPaddingNumber(currentNumberFormat,buf, value, 2, 2); // clip 1996 to 96 } else { //count = 1 or count > 2 zeroPaddingNumber(currentNumberFormat,buf, value, count, maxIntCount); } break; case 2: // 'M' - MONTH case 26: // 'L' - STANDALONE MONTH if ( cal.getType().equals("hebrew")) { boolean isLeap = HebrewCalendar.isLeapYear(cal.get(Calendar.YEAR)); if (isLeap && value == 6 && count >= 3 ) { value = 13; // Show alternate form for Adar II in leap years in Hebrew calendar. } if (!isLeap && value >= 6 && count < 3 ) { value--; // Adjust the month number down 1 in Hebrew non-leap years, i.e. Adar is 6, not 7. } } int isLeapMonth = (formatData.leapMonthPatterns != null && formatData.leapMonthPatterns.length >= DateFormatSymbols.DT_MONTH_PATTERN_COUNT)? cal.get(Calendar.IS_LEAP_MONTH): 0; // should consolidate the next section by using arrays of pointers & counts for the right symbols... if (count == 5) { if (patternCharIndex == 2) { safeAppendWithMonthPattern(formatData.narrowMonths, value, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_FORMAT_NARROW]: null); } else { safeAppendWithMonthPattern(formatData.standaloneNarrowMonths, value, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_STANDALONE_NARROW]: null); } capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.MONTH_NARROW; } else if (count == 4) { if (patternCharIndex == 2) { safeAppendWithMonthPattern(formatData.months, value, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_FORMAT_WIDE]: null); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.MONTH_FORMAT; } else { safeAppendWithMonthPattern(formatData.standaloneMonths, value, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_STANDALONE_WIDE]: null); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.MONTH_STANDALONE; } } else if (count == 3) { if (patternCharIndex == 2) { safeAppendWithMonthPattern(formatData.shortMonths, value, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_FORMAT_ABBREV]: null); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.MONTH_FORMAT; } else { safeAppendWithMonthPattern(formatData.standaloneShortMonths, value, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_STANDALONE_ABBREV]: null); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.MONTH_STANDALONE; } } else { StringBuffer monthNumber = new StringBuffer(); zeroPaddingNumber(currentNumberFormat, monthNumber, value+1, count, maxIntCount); String[] monthNumberStrings = new String[1]; monthNumberStrings[0] = monthNumber.toString(); safeAppendWithMonthPattern(monthNumberStrings, 0, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_NUMERIC]: null); } break; case 4: // 'k' - HOUR_OF_DAY (1..24) if (value == 0) { zeroPaddingNumber(currentNumberFormat,buf, cal.getMaximum(Calendar.HOUR_OF_DAY)+1, count, maxIntCount); } else { zeroPaddingNumber(currentNumberFormat,buf, value, count, maxIntCount); } break; case 8: // 'S' - FRACTIONAL_SECOND // Fractional seconds left-justify { numberFormat.setMinimumIntegerDigits(Math.min(3, count)); numberFormat.setMaximumIntegerDigits(maxIntCount); if (count == 1) { value /= 100; } else if (count == 2) { value /= 10; } FieldPosition p = new FieldPosition(-1); numberFormat.format(value, buf, p); if (count > 3) { numberFormat.setMinimumIntegerDigits(count - 3); numberFormat.format(0L, buf, p); } } break; case 19: // 'e' - DOW_LOCAL (use DOW_LOCAL for numeric, DAY_OF_WEEK for format names) if (count < 3) { zeroPaddingNumber(currentNumberFormat,buf, value, count, maxIntCount); break; } // For alpha day-of-week, we don't want DOW_LOCAL, // we need the standard DAY_OF_WEEK. value = cal.get(Calendar.DAY_OF_WEEK); // fall through, do not break here case 9: // 'E' - DAY_OF_WEEK if (count == 5) { safeAppend(formatData.narrowWeekdays, value, buf); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_NARROW; } else if (count == 4) { safeAppend(formatData.weekdays, value, buf); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_FORMAT; } else if (count == 6 && formatData.shorterWeekdays != null) { safeAppend(formatData.shorterWeekdays, value, buf); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_FORMAT; } else {// count <= 3, use abbreviated form if exists safeAppend(formatData.shortWeekdays, value, buf); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_FORMAT; } break; case 14: // 'a' - AM_PM // formatData.ampmsNarrow may be null when deserializing DateFormatSymbolsfrom old version if (count < 5 || formatData.ampmsNarrow == null) { safeAppend(formatData.ampms, value, buf); } else { safeAppend(formatData.ampmsNarrow, value, buf); } break; case 15: // 'h' - HOUR (1..12) if (value == 0) { zeroPaddingNumber(currentNumberFormat,buf, cal.getLeastMaximum(Calendar.HOUR)+1, count, maxIntCount); } else { zeroPaddingNumber(currentNumberFormat,buf, value, count, maxIntCount); } break; case 17: // 'z' - TIMEZONE_FIELD if (count < 4) { // "z", "zz", "zzz" result = tzFormat().format(Style.SPECIFIC_SHORT, tz, date); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.METAZONE_SHORT; } else { result = tzFormat().format(Style.SPECIFIC_LONG, tz, date); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.METAZONE_LONG; } buf.append(result); break; case 23: // 'Z' - TIMEZONE_RFC_FIELD if (count < 4) { // RFC822 format - equivalent to ISO 8601 local offset fixed width format result = tzFormat().format(Style.ISO_BASIC_LOCAL_FULL, tz, date); } else if (count == 5) { // ISO 8601 extended format result = tzFormat().format(Style.ISO_EXTENDED_FULL, tz, date); } else { // long form, localized GMT pattern result = tzFormat().format(Style.LOCALIZED_GMT, tz, date); } buf.append(result); break; case 24: // 'v' - TIMEZONE_GENERIC_FIELD if (count == 1) { // "v" result = tzFormat().format(Style.GENERIC_SHORT, tz, date); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.METAZONE_SHORT; } else if (count == 4) { // "vvvv" result = tzFormat().format(Style.GENERIC_LONG, tz, date); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.METAZONE_LONG; } buf.append(result); break; case 29: // 'V' - TIMEZONE_SPECIAL_FIELD if (count == 1) { // "V" result = tzFormat().format(Style.ZONE_ID_SHORT, tz, date); } else if (count == 2) { // "VV" result = tzFormat().format(Style.ZONE_ID, tz, date); } else if (count == 3) { // "VVV" result = tzFormat().format(Style.EXEMPLAR_LOCATION, tz, date); } else if (count == 4) { // "VVVV" result = tzFormat().format(Style.GENERIC_LOCATION, tz, date); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.ZONE_LONG; } buf.append(result); break; case 31: // 'O' - TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD if (count == 1) { // "O" - Short Localized GMT format result = tzFormat().format(Style.LOCALIZED_GMT_SHORT, tz, date); } else if (count == 4) { // "OOOO" - Localized GMT format result = tzFormat().format(Style.LOCALIZED_GMT, tz, date); } buf.append(result); break; case 32: // 'X' - TIMEZONE_ISO_FIELD if (count == 1) { // "X" - ISO Basic/Short result = tzFormat().format(Style.ISO_BASIC_SHORT, tz, date); } else if (count == 2) { // "XX" - ISO Basic/Fixed result = tzFormat().format(Style.ISO_BASIC_FIXED, tz, date); } else if (count == 3) { // "XXX" - ISO Extended/Fixed result = tzFormat().format(Style.ISO_EXTENDED_FIXED, tz, date); } else if (count == 4) { // "XXXX" - ISO Basic/Optional second field result = tzFormat().format(Style.ISO_BASIC_FULL, tz, date); } else if (count == 5) { // "XXXXX" - ISO Extended/Optional second field result = tzFormat().format(Style.ISO_EXTENDED_FULL, tz, date); } buf.append(result); break; case 33: // 'x' - TIMEZONE_ISO_LOCAL_FIELD if (count == 1) { // "x" - ISO Local Basic/Short result = tzFormat().format(Style.ISO_BASIC_LOCAL_SHORT, tz, date); } else if (count == 2) { // "x" - ISO Local Basic/Fixed result = tzFormat().format(Style.ISO_BASIC_LOCAL_FIXED, tz, date); } else if (count == 3) { // "xxx" - ISO Local Extended/Fixed result = tzFormat().format(Style.ISO_EXTENDED_LOCAL_FIXED, tz, date); } else if (count == 4) { // "xxxx" - ISO Local Basic/Optional second field result = tzFormat().format(Style.ISO_BASIC_LOCAL_FULL, tz, date); } else if (count == 5) { // "xxxxx" - ISO Local Extended/Optional second field result = tzFormat().format(Style.ISO_EXTENDED_LOCAL_FULL, tz, date); } buf.append(result); break; case 25: // 'c' - STANDALONE DAY (use DOW_LOCAL for numeric, DAY_OF_WEEK for standalone) if (count < 3) { zeroPaddingNumber(currentNumberFormat,buf, value, 1, maxIntCount); break; } // For alpha day-of-week, we don't want DOW_LOCAL, // we need the standard DAY_OF_WEEK. value = cal.get(Calendar.DAY_OF_WEEK); if (count == 5) { safeAppend(formatData.standaloneNarrowWeekdays, value, buf); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_NARROW; } else if (count == 4) { safeAppend(formatData.standaloneWeekdays, value, buf); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_STANDALONE; } else if (count == 6 && formatData.standaloneShorterWeekdays != null) { safeAppend(formatData.standaloneShorterWeekdays, value, buf); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_STANDALONE; } else { // count == 3 safeAppend(formatData.standaloneShortWeekdays, value, buf); capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_STANDALONE; } break; case 27: // 'Q' - QUARTER if (count >= 4) { safeAppend(formatData.quarters, value/3, buf); } else if (count == 3) { safeAppend(formatData.shortQuarters, value/3, buf); } else { zeroPaddingNumber(currentNumberFormat,buf, (value/3)+1, count, maxIntCount); } break; case 28: // 'q' - STANDALONE QUARTER if (count >= 4) { safeAppend(formatData.standaloneQuarters, value/3, buf); } else if (count == 3) { safeAppend(formatData.standaloneShortQuarters, value/3, buf); } else { zeroPaddingNumber(currentNumberFormat,buf, (value/3)+1, count, maxIntCount); } break; case 35: // 'b' - am/pm/noon/midnight { // Note: "midnight" can be ambiguous as to whether it refers to beginning of day or end of day. // For ICU 57 output of "midnight" is temporarily suppressed. int hour = cal.get(Calendar.HOUR_OF_DAY); String toAppend = null; // For "midnight" and "noon": // Time, as displayed, must be exactly noon or midnight. // This means minutes and seconds, if present, must be zero. if ((/*hour == 0 ||*/ hour == 12) && (!hasMinute || cal.get(Calendar.MINUTE) == 0) && (!hasSecond || cal.get(Calendar.SECOND) == 0)) { // Stealing am/pm value to use as our array index. // It works out: am/midnight are both 0, pm/noon are both 1, // 12 am is 12 midnight, and 12 pm is 12 noon. value = cal.get(Calendar.AM_PM); if (count == 3) { toAppend = formatData.abbreviatedDayPeriods[value]; } else if (count == 4 || count > 5) { toAppend = formatData.wideDayPeriods[value]; } else { // count == 5 toAppend = formatData.narrowDayPeriods[value]; } } if (toAppend == null) { // Time isn't exactly midnight or noon (as displayed) or localized string doesn't // exist for requested period. Fall back to am/pm instead. subFormat(buf, 'a', count, beginOffset, fieldNum, capitalizationContext, pos, cal); } else { buf.append(toAppend); } break; } case 36: // 'B' - flexible day period { // TODO: Maybe fetch the DayperiodRules during initialization (instead of at the first // loading of an instance) if a relevant pattern character (b or B) is used. DayPeriodRules ruleSet = DayPeriodRules.getInstance(getLocale()); if (ruleSet == null) { // Data doesn't exist for the locale we're looking for. // Fall back to am/pm. subFormat(buf, 'a', count, beginOffset, fieldNum, capitalizationContext, pos, cal); break; } // Get current display time. int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = 0; int second = 0; if (hasMinute) { minute = cal.get(Calendar.MINUTE); } if (hasSecond) { second = cal.get(Calendar.SECOND); } // Determine day period. DayPeriodRules.DayPeriod periodType; if (hour == 0 && minute == 0 && second == 0 && ruleSet.hasMidnight()) { periodType = DayPeriodRules.DayPeriod.MIDNIGHT; } else if (hour == 12 && minute == 0 && second == 0 && ruleSet.hasNoon()) { periodType = DayPeriodRules.DayPeriod.NOON; } else { periodType = ruleSet.getDayPeriodForHour(hour); } // Note: "midnight" can be ambiguous as to whether it refers to beginning of day or end of day. // For ICU 57 output of "midnight" is temporarily suppressed. // Rule set exists, therefore periodType can't be null. // Get localized string. assert(periodType != null); String toAppend = null; int index; if (periodType != DayPeriodRules.DayPeriod.AM && periodType != DayPeriodRules.DayPeriod.PM && periodType != DayPeriodRules.DayPeriod.MIDNIGHT) { index = periodType.ordinal(); if (count <= 3) { toAppend = formatData.abbreviatedDayPeriods[index]; // i.e. short } else if (count == 4 || count > 5) { toAppend = formatData.wideDayPeriods[index]; } else { // count == 5 toAppend = formatData.narrowDayPeriods[index]; } } // Fallback schedule: // Midnight/Noon -> General Periods -> AM/PM. // Midnight/Noon -> General Periods. if (toAppend == null && (periodType == DayPeriodRules.DayPeriod.MIDNIGHT || periodType == DayPeriodRules.DayPeriod.NOON)) { periodType = ruleSet.getDayPeriodForHour(hour); index = periodType.ordinal(); if (count <= 3) { toAppend = formatData.abbreviatedDayPeriods[index]; // i.e. short } else if (count == 4 || count > 5) { toAppend = formatData.wideDayPeriods[index]; } else { // count == 5 toAppend = formatData.narrowDayPeriods[index]; } } // General Periods -> AM/PM. if (periodType == DayPeriodRules.DayPeriod.AM || periodType == DayPeriodRules.DayPeriod.PM || toAppend == null) { subFormat(buf, 'a', count, beginOffset, fieldNum, capitalizationContext, pos, cal); } else { buf.append(toAppend); } break; } case 37: // TIME SEPARATOR (no pattern character currently defined, we should // not get here but leave support in for future definition. buf.append(formatData.getTimeSeparatorString()); break; default: // case 3: // 'd' - DATE // case 5: // 'H' - HOUR_OF_DAY (0..23) // case 6: // 'm' - MINUTE // case 7: // 's' - SECOND // case 10: // 'D' - DAY_OF_YEAR // case 11: // 'F' - DAY_OF_WEEK_IN_MONTH // case 12: // 'w' - WEEK_OF_YEAR // case 13: // 'W' - WEEK_OF_MONTH // case 16: // 'K' - HOUR (0..11) // case 20: // 'u' - EXTENDED_YEAR // case 21: // 'g' - JULIAN_DAY // case 22: // 'A' - MILLISECONDS_IN_DAY zeroPaddingNumber(currentNumberFormat,buf, value, count, maxIntCount); break; } // switch (patternCharIndex) if (fieldNum == 0 && capitalizationContext != null && UCharacter.isLowerCase(buf.codePointAt(bufstart))) { boolean titlecase = false; switch (capitalizationContext) { case CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE: titlecase = true; break; case CAPITALIZATION_FOR_UI_LIST_OR_MENU: case CAPITALIZATION_FOR_STANDALONE: if (formatData.capitalization != null) { boolean[] transforms = formatData.capitalization.get(capContextUsageType); titlecase = (capitalizationContext==DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU)? transforms[0]: transforms[1]; } break; default: break; } if (titlecase) { if (capitalizationBrkIter == null) { // should only happen when deserializing, etc. capitalizationBrkIter = BreakIterator.getSentenceInstance(locale); } String firstField = buf.substring(bufstart); // bufstart or beginOffset, should be the same String firstFieldTitleCase = UCharacter.toTitleCase(locale, firstField, capitalizationBrkIter, UCharacter.TITLECASE_NO_LOWERCASE | UCharacter.TITLECASE_NO_BREAK_ADJUSTMENT); buf.replace(bufstart, buf.length(), firstFieldTitleCase); } } // Set the FieldPosition (for the first occurrence only) if (pos.getBeginIndex() == pos.getEndIndex()) { if (pos.getField() == PATTERN_INDEX_TO_DATE_FORMAT_FIELD[patternCharIndex]) { pos.setBeginIndex(beginOffset); pos.setEndIndex(beginOffset + buf.length() - bufstart); } else if (pos.getFieldAttribute() == PATTERN_INDEX_TO_DATE_FORMAT_ATTRIBUTE[patternCharIndex]) { pos.setBeginIndex(beginOffset); pos.setEndIndex(beginOffset + buf.length() - bufstart); } } } }
public class class_name { @Deprecated @SuppressWarnings("fallthrough") protected void subFormat(StringBuffer buf, char ch, int count, int beginOffset, int fieldNum, DisplayContext capitalizationContext, FieldPosition pos, Calendar cal) { final int maxIntCount = Integer.MAX_VALUE; final int bufstart = buf.length(); TimeZone tz = cal.getTimeZone(); long date = cal.getTimeInMillis(); String result = null; int patternCharIndex = getIndexFromChar(ch); if (patternCharIndex == -1) { if (ch == 'l') { // (SMALL LETTER L) deprecated placeholder for leap month marker, ignore return; // depends on control dependency: [if], data = [none] } else { throw new IllegalArgumentException("Illegal pattern character " + "'" + ch + "' in \"" + pattern + '"'); } } final int field = PATTERN_INDEX_TO_CALENDAR_FIELD[patternCharIndex]; int value = 0; // Don't get value unless it is useful if (field >= 0) { value = (patternCharIndex != DateFormat.RELATED_YEAR)? cal.get(field): cal.getRelatedYear(); // depends on control dependency: [if], data = [(field] } NumberFormat currentNumberFormat = getNumberFormat(ch); DateFormatSymbols.CapitalizationContextUsage capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.OTHER; switch (patternCharIndex) { case 0: // 'G' - ERA if ( cal.getType().equals("chinese") || cal.getType().equals("dangi") ) { // moved from ChineseDateFormat zeroPaddingNumber(currentNumberFormat, buf, value, 1, 9); // depends on control dependency: [if], data = [none] } else { if (count == 5) { safeAppend(formatData.narrowEras, value, buf); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.ERA_NARROW; // depends on control dependency: [if], data = [none] } else if (count == 4) { safeAppend(formatData.eraNames, value, buf); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.ERA_WIDE; // depends on control dependency: [if], data = [none] } else { safeAppend(formatData.eras, value, buf); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.ERA_ABBREV; // depends on control dependency: [if], data = [none] } } break; case 30: // 'U' - YEAR_NAME_FIELD if (formatData.shortYearNames != null && value <= formatData.shortYearNames.length) { safeAppend(formatData.shortYearNames, value-1, buf); // depends on control dependency: [if], data = [(formatData.shortYearNames] break; } // else fall through to numeric year handling, do not break here case 1: // 'y' - YEAR case 18: // 'Y' - YEAR_WOY if ( override != null && (override.compareTo("hebr") == 0 || override.indexOf("y=hebr") >= 0) && value > HEBREW_CAL_CUR_MILLENIUM_START_YEAR && value < HEBREW_CAL_CUR_MILLENIUM_END_YEAR ) { value -= HEBREW_CAL_CUR_MILLENIUM_START_YEAR; // depends on control dependency: [if], data = [none] } /* According to the specification, if the number of pattern letters ('y') is 2, * the year is truncated to 2 digits; otherwise it is interpreted as a number. * But the original code process 'y', 'yy', 'yyy' in the same way. and process * patterns with 4 or more than 4 'y' characters in the same way. * So I change the codes to meet the specification. [Richard/GCl] */ if (count == 2) { zeroPaddingNumber(currentNumberFormat,buf, value, 2, 2); // clip 1996 to 96 // depends on control dependency: [if], data = [2)] } else { //count = 1 or count > 2 zeroPaddingNumber(currentNumberFormat,buf, value, count, maxIntCount); // depends on control dependency: [if], data = [none] } break; case 2: // 'M' - MONTH case 26: // 'L' - STANDALONE MONTH if ( cal.getType().equals("hebrew")) { boolean isLeap = HebrewCalendar.isLeapYear(cal.get(Calendar.YEAR)); if (isLeap && value == 6 && count >= 3 ) { value = 13; // Show alternate form for Adar II in leap years in Hebrew calendar. // depends on control dependency: [if], data = [none] } if (!isLeap && value >= 6 && count < 3 ) { value--; // Adjust the month number down 1 in Hebrew non-leap years, i.e. Adar is 6, not 7. // depends on control dependency: [if], data = [none] } } int isLeapMonth = (formatData.leapMonthPatterns != null && formatData.leapMonthPatterns.length >= DateFormatSymbols.DT_MONTH_PATTERN_COUNT)? cal.get(Calendar.IS_LEAP_MONTH): 0; // should consolidate the next section by using arrays of pointers & counts for the right symbols... if (count == 5) { if (patternCharIndex == 2) { safeAppendWithMonthPattern(formatData.narrowMonths, value, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_FORMAT_NARROW]: null); // depends on control dependency: [if], data = [none] } else { safeAppendWithMonthPattern(formatData.standaloneNarrowMonths, value, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_STANDALONE_NARROW]: null); // depends on control dependency: [if], data = [none] } capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.MONTH_NARROW; // depends on control dependency: [if], data = [none] } else if (count == 4) { if (patternCharIndex == 2) { safeAppendWithMonthPattern(formatData.months, value, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_FORMAT_WIDE]: null); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.MONTH_FORMAT; // depends on control dependency: [if], data = [none] } else { safeAppendWithMonthPattern(formatData.standaloneMonths, value, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_STANDALONE_WIDE]: null); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.MONTH_STANDALONE; // depends on control dependency: [if], data = [none] } } else if (count == 3) { if (patternCharIndex == 2) { safeAppendWithMonthPattern(formatData.shortMonths, value, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_FORMAT_ABBREV]: null); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.MONTH_FORMAT; // depends on control dependency: [if], data = [none] } else { safeAppendWithMonthPattern(formatData.standaloneShortMonths, value, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_STANDALONE_ABBREV]: null); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.MONTH_STANDALONE; // depends on control dependency: [if], data = [none] } } else { StringBuffer monthNumber = new StringBuffer(); zeroPaddingNumber(currentNumberFormat, monthNumber, value+1, count, maxIntCount); // depends on control dependency: [if], data = [none] String[] monthNumberStrings = new String[1]; monthNumberStrings[0] = monthNumber.toString(); // depends on control dependency: [if], data = [none] safeAppendWithMonthPattern(monthNumberStrings, 0, buf, (isLeapMonth!=0)? formatData.leapMonthPatterns[DateFormatSymbols.DT_LEAP_MONTH_PATTERN_NUMERIC]: null); // depends on control dependency: [if], data = [none] } break; case 4: // 'k' - HOUR_OF_DAY (1..24) if (value == 0) { zeroPaddingNumber(currentNumberFormat,buf, cal.getMaximum(Calendar.HOUR_OF_DAY)+1, count, maxIntCount); // depends on control dependency: [if], data = [none] } else { zeroPaddingNumber(currentNumberFormat,buf, value, count, maxIntCount); // depends on control dependency: [if], data = [none] } break; case 8: // 'S' - FRACTIONAL_SECOND // Fractional seconds left-justify { numberFormat.setMinimumIntegerDigits(Math.min(3, count)); numberFormat.setMaximumIntegerDigits(maxIntCount); if (count == 1) { value /= 100; // depends on control dependency: [if], data = [none] } else if (count == 2) { value /= 10; // depends on control dependency: [if], data = [none] } FieldPosition p = new FieldPosition(-1); numberFormat.format(value, buf, p); if (count > 3) { numberFormat.setMinimumIntegerDigits(count - 3); // depends on control dependency: [if], data = [(count] numberFormat.format(0L, buf, p); // depends on control dependency: [if], data = [none] } } break; case 19: // 'e' - DOW_LOCAL (use DOW_LOCAL for numeric, DAY_OF_WEEK for format names) if (count < 3) { zeroPaddingNumber(currentNumberFormat,buf, value, count, maxIntCount); // depends on control dependency: [if], data = [none] break; } // For alpha day-of-week, we don't want DOW_LOCAL, // we need the standard DAY_OF_WEEK. value = cal.get(Calendar.DAY_OF_WEEK); // fall through, do not break here case 9: // 'E' - DAY_OF_WEEK if (count == 5) { safeAppend(formatData.narrowWeekdays, value, buf); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_NARROW; // depends on control dependency: [if], data = [none] } else if (count == 4) { safeAppend(formatData.weekdays, value, buf); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_FORMAT; // depends on control dependency: [if], data = [none] } else if (count == 6 && formatData.shorterWeekdays != null) { safeAppend(formatData.shorterWeekdays, value, buf); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_FORMAT; // depends on control dependency: [if], data = [none] } else {// count <= 3, use abbreviated form if exists safeAppend(formatData.shortWeekdays, value, buf); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_FORMAT; // depends on control dependency: [if], data = [none] } break; case 14: // 'a' - AM_PM // formatData.ampmsNarrow may be null when deserializing DateFormatSymbolsfrom old version if (count < 5 || formatData.ampmsNarrow == null) { safeAppend(formatData.ampms, value, buf); // depends on control dependency: [if], data = [none] } else { safeAppend(formatData.ampmsNarrow, value, buf); // depends on control dependency: [if], data = [none] } break; case 15: // 'h' - HOUR (1..12) if (value == 0) { zeroPaddingNumber(currentNumberFormat,buf, cal.getLeastMaximum(Calendar.HOUR)+1, count, maxIntCount); // depends on control dependency: [if], data = [none] } else { zeroPaddingNumber(currentNumberFormat,buf, value, count, maxIntCount); // depends on control dependency: [if], data = [none] } break; case 17: // 'z' - TIMEZONE_FIELD if (count < 4) { // "z", "zz", "zzz" result = tzFormat().format(Style.SPECIFIC_SHORT, tz, date); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.METAZONE_SHORT; // depends on control dependency: [if], data = [none] } else { result = tzFormat().format(Style.SPECIFIC_LONG, tz, date); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.METAZONE_LONG; // depends on control dependency: [if], data = [none] } buf.append(result); break; case 23: // 'Z' - TIMEZONE_RFC_FIELD if (count < 4) { // RFC822 format - equivalent to ISO 8601 local offset fixed width format result = tzFormat().format(Style.ISO_BASIC_LOCAL_FULL, tz, date); // depends on control dependency: [if], data = [none] } else if (count == 5) { // ISO 8601 extended format result = tzFormat().format(Style.ISO_EXTENDED_FULL, tz, date); // depends on control dependency: [if], data = [none] } else { // long form, localized GMT pattern result = tzFormat().format(Style.LOCALIZED_GMT, tz, date); // depends on control dependency: [if], data = [none] } buf.append(result); break; case 24: // 'v' - TIMEZONE_GENERIC_FIELD if (count == 1) { // "v" result = tzFormat().format(Style.GENERIC_SHORT, tz, date); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.METAZONE_SHORT; // depends on control dependency: [if], data = [none] } else if (count == 4) { // "vvvv" result = tzFormat().format(Style.GENERIC_LONG, tz, date); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.METAZONE_LONG; // depends on control dependency: [if], data = [none] } buf.append(result); break; case 29: // 'V' - TIMEZONE_SPECIAL_FIELD if (count == 1) { // "V" result = tzFormat().format(Style.ZONE_ID_SHORT, tz, date); // depends on control dependency: [if], data = [none] } else if (count == 2) { // "VV" result = tzFormat().format(Style.ZONE_ID, tz, date); // depends on control dependency: [if], data = [none] } else if (count == 3) { // "VVV" result = tzFormat().format(Style.EXEMPLAR_LOCATION, tz, date); // depends on control dependency: [if], data = [none] } else if (count == 4) { // "VVVV" result = tzFormat().format(Style.GENERIC_LOCATION, tz, date); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.ZONE_LONG; // depends on control dependency: [if], data = [none] } buf.append(result); break; case 31: // 'O' - TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD if (count == 1) { // "O" - Short Localized GMT format result = tzFormat().format(Style.LOCALIZED_GMT_SHORT, tz, date); // depends on control dependency: [if], data = [none] } else if (count == 4) { // "OOOO" - Localized GMT format result = tzFormat().format(Style.LOCALIZED_GMT, tz, date); // depends on control dependency: [if], data = [none] } buf.append(result); break; case 32: // 'X' - TIMEZONE_ISO_FIELD if (count == 1) { // "X" - ISO Basic/Short result = tzFormat().format(Style.ISO_BASIC_SHORT, tz, date); // depends on control dependency: [if], data = [none] } else if (count == 2) { // "XX" - ISO Basic/Fixed result = tzFormat().format(Style.ISO_BASIC_FIXED, tz, date); // depends on control dependency: [if], data = [none] } else if (count == 3) { // "XXX" - ISO Extended/Fixed result = tzFormat().format(Style.ISO_EXTENDED_FIXED, tz, date); // depends on control dependency: [if], data = [none] } else if (count == 4) { // "XXXX" - ISO Basic/Optional second field result = tzFormat().format(Style.ISO_BASIC_FULL, tz, date); // depends on control dependency: [if], data = [none] } else if (count == 5) { // "XXXXX" - ISO Extended/Optional second field result = tzFormat().format(Style.ISO_EXTENDED_FULL, tz, date); // depends on control dependency: [if], data = [none] } buf.append(result); break; case 33: // 'x' - TIMEZONE_ISO_LOCAL_FIELD if (count == 1) { // "x" - ISO Local Basic/Short result = tzFormat().format(Style.ISO_BASIC_LOCAL_SHORT, tz, date); // depends on control dependency: [if], data = [none] } else if (count == 2) { // "x" - ISO Local Basic/Fixed result = tzFormat().format(Style.ISO_BASIC_LOCAL_FIXED, tz, date); // depends on control dependency: [if], data = [none] } else if (count == 3) { // "xxx" - ISO Local Extended/Fixed result = tzFormat().format(Style.ISO_EXTENDED_LOCAL_FIXED, tz, date); // depends on control dependency: [if], data = [none] } else if (count == 4) { // "xxxx" - ISO Local Basic/Optional second field result = tzFormat().format(Style.ISO_BASIC_LOCAL_FULL, tz, date); // depends on control dependency: [if], data = [none] } else if (count == 5) { // "xxxxx" - ISO Local Extended/Optional second field result = tzFormat().format(Style.ISO_EXTENDED_LOCAL_FULL, tz, date); // depends on control dependency: [if], data = [none] } buf.append(result); break; case 25: // 'c' - STANDALONE DAY (use DOW_LOCAL for numeric, DAY_OF_WEEK for standalone) if (count < 3) { zeroPaddingNumber(currentNumberFormat,buf, value, 1, maxIntCount); // depends on control dependency: [if], data = [none] break; } // For alpha day-of-week, we don't want DOW_LOCAL, // we need the standard DAY_OF_WEEK. value = cal.get(Calendar.DAY_OF_WEEK); if (count == 5) { safeAppend(formatData.standaloneNarrowWeekdays, value, buf); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_NARROW; // depends on control dependency: [if], data = [none] } else if (count == 4) { safeAppend(formatData.standaloneWeekdays, value, buf); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_STANDALONE; // depends on control dependency: [if], data = [none] } else if (count == 6 && formatData.standaloneShorterWeekdays != null) { safeAppend(formatData.standaloneShorterWeekdays, value, buf); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_STANDALONE; // depends on control dependency: [if], data = [none] } else { // count == 3 safeAppend(formatData.standaloneShortWeekdays, value, buf); // depends on control dependency: [if], data = [none] capContextUsageType = DateFormatSymbols.CapitalizationContextUsage.DAY_STANDALONE; // depends on control dependency: [if], data = [none] } break; case 27: // 'Q' - QUARTER if (count >= 4) { safeAppend(formatData.quarters, value/3, buf); // depends on control dependency: [if], data = [none] } else if (count == 3) { safeAppend(formatData.shortQuarters, value/3, buf); // depends on control dependency: [if], data = [none] } else { zeroPaddingNumber(currentNumberFormat,buf, (value/3)+1, count, maxIntCount); // depends on control dependency: [if], data = [3)] } break; case 28: // 'q' - STANDALONE QUARTER if (count >= 4) { safeAppend(formatData.standaloneQuarters, value/3, buf); // depends on control dependency: [if], data = [none] } else if (count == 3) { safeAppend(formatData.standaloneShortQuarters, value/3, buf); // depends on control dependency: [if], data = [none] } else { zeroPaddingNumber(currentNumberFormat,buf, (value/3)+1, count, maxIntCount); // depends on control dependency: [if], data = [3)] } break; case 35: // 'b' - am/pm/noon/midnight { // Note: "midnight" can be ambiguous as to whether it refers to beginning of day or end of day. // For ICU 57 output of "midnight" is temporarily suppressed. int hour = cal.get(Calendar.HOUR_OF_DAY); String toAppend = null; // For "midnight" and "noon": // Time, as displayed, must be exactly noon or midnight. // This means minutes and seconds, if present, must be zero. if ((/*hour == 0 ||*/ hour == 12) && (!hasMinute || cal.get(Calendar.MINUTE) == 0) && (!hasSecond || cal.get(Calendar.SECOND) == 0)) { // Stealing am/pm value to use as our array index. // It works out: am/midnight are both 0, pm/noon are both 1, // 12 am is 12 midnight, and 12 pm is 12 noon. value = cal.get(Calendar.AM_PM); // depends on control dependency: [if], data = [none] if (count == 3) { toAppend = formatData.abbreviatedDayPeriods[value]; // depends on control dependency: [if], data = [none] } else if (count == 4 || count > 5) { toAppend = formatData.wideDayPeriods[value]; // depends on control dependency: [if], data = [none] } else { // count == 5 toAppend = formatData.narrowDayPeriods[value]; // depends on control dependency: [if], data = [none] } } if (toAppend == null) { // Time isn't exactly midnight or noon (as displayed) or localized string doesn't // exist for requested period. Fall back to am/pm instead. subFormat(buf, 'a', count, beginOffset, fieldNum, capitalizationContext, pos, cal); // depends on control dependency: [if], data = [none] } else { buf.append(toAppend); // depends on control dependency: [if], data = [(toAppend] } break; } case 36: // 'B' - flexible day period { // TODO: Maybe fetch the DayperiodRules during initialization (instead of at the first // loading of an instance) if a relevant pattern character (b or B) is used. DayPeriodRules ruleSet = DayPeriodRules.getInstance(getLocale()); if (ruleSet == null) { // Data doesn't exist for the locale we're looking for. // Fall back to am/pm. subFormat(buf, 'a', count, beginOffset, fieldNum, capitalizationContext, pos, cal); // depends on control dependency: [if], data = [none] break; } // Get current display time. int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = 0; int second = 0; if (hasMinute) { minute = cal.get(Calendar.MINUTE); } // depends on control dependency: [if], data = [none] if (hasSecond) { second = cal.get(Calendar.SECOND); } // depends on control dependency: [if], data = [none] // Determine day period. DayPeriodRules.DayPeriod periodType; if (hour == 0 && minute == 0 && second == 0 && ruleSet.hasMidnight()) { periodType = DayPeriodRules.DayPeriod.MIDNIGHT; // depends on control dependency: [if], data = [none] } else if (hour == 12 && minute == 0 && second == 0 && ruleSet.hasNoon()) { periodType = DayPeriodRules.DayPeriod.NOON; // depends on control dependency: [if], data = [none] } else { periodType = ruleSet.getDayPeriodForHour(hour); // depends on control dependency: [if], data = [(hour] } // Note: "midnight" can be ambiguous as to whether it refers to beginning of day or end of day. // For ICU 57 output of "midnight" is temporarily suppressed. // Rule set exists, therefore periodType can't be null. // Get localized string. assert(periodType != null); String toAppend = null; int index; if (periodType != DayPeriodRules.DayPeriod.AM && periodType != DayPeriodRules.DayPeriod.PM && periodType != DayPeriodRules.DayPeriod.MIDNIGHT) { index = periodType.ordinal(); // depends on control dependency: [if], data = [none] if (count <= 3) { toAppend = formatData.abbreviatedDayPeriods[index]; // i.e. short // depends on control dependency: [if], data = [none] } else if (count == 4 || count > 5) { toAppend = formatData.wideDayPeriods[index]; // depends on control dependency: [if], data = [none] } else { // count == 5 toAppend = formatData.narrowDayPeriods[index]; // depends on control dependency: [if], data = [none] } } // Fallback schedule: // Midnight/Noon -> General Periods -> AM/PM. // Midnight/Noon -> General Periods. if (toAppend == null && (periodType == DayPeriodRules.DayPeriod.MIDNIGHT || periodType == DayPeriodRules.DayPeriod.NOON)) { periodType = ruleSet.getDayPeriodForHour(hour); // depends on control dependency: [if], data = [none] index = periodType.ordinal(); // depends on control dependency: [if], data = [none] if (count <= 3) { toAppend = formatData.abbreviatedDayPeriods[index]; // i.e. short // depends on control dependency: [if], data = [none] } else if (count == 4 || count > 5) { toAppend = formatData.wideDayPeriods[index]; // depends on control dependency: [if], data = [none] } else { // count == 5 toAppend = formatData.narrowDayPeriods[index]; // depends on control dependency: [if], data = [none] } } // General Periods -> AM/PM. if (periodType == DayPeriodRules.DayPeriod.AM || periodType == DayPeriodRules.DayPeriod.PM || toAppend == null) { subFormat(buf, 'a', count, beginOffset, fieldNum, capitalizationContext, pos, cal); // depends on control dependency: [if], data = [none] } else { buf.append(toAppend); // depends on control dependency: [if], data = [none] } break; } case 37: // TIME SEPARATOR (no pattern character currently defined, we should // not get here but leave support in for future definition. buf.append(formatData.getTimeSeparatorString()); break; default: // case 3: // 'd' - DATE // case 5: // 'H' - HOUR_OF_DAY (0..23) // case 6: // 'm' - MINUTE // case 7: // 's' - SECOND // case 10: // 'D' - DAY_OF_YEAR // case 11: // 'F' - DAY_OF_WEEK_IN_MONTH // case 12: // 'w' - WEEK_OF_YEAR // case 13: // 'W' - WEEK_OF_MONTH // case 16: // 'K' - HOUR (0..11) // case 20: // 'u' - EXTENDED_YEAR // case 21: // 'g' - JULIAN_DAY // case 22: // 'A' - MILLISECONDS_IN_DAY zeroPaddingNumber(currentNumberFormat,buf, value, count, maxIntCount); break; } // switch (patternCharIndex) if (fieldNum == 0 && capitalizationContext != null && UCharacter.isLowerCase(buf.codePointAt(bufstart))) { boolean titlecase = false; switch (capitalizationContext) { case CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE: titlecase = true; break; case CAPITALIZATION_FOR_UI_LIST_OR_MENU: case CAPITALIZATION_FOR_STANDALONE: if (formatData.capitalization != null) { boolean[] transforms = formatData.capitalization.get(capContextUsageType); titlecase = (capitalizationContext==DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU)? transforms[0]: transforms[1]; // depends on control dependency: [if], data = [none] } break; default: break; } if (titlecase) { if (capitalizationBrkIter == null) { // should only happen when deserializing, etc. capitalizationBrkIter = BreakIterator.getSentenceInstance(locale); // depends on control dependency: [if], data = [none] } String firstField = buf.substring(bufstart); // bufstart or beginOffset, should be the same String firstFieldTitleCase = UCharacter.toTitleCase(locale, firstField, capitalizationBrkIter, UCharacter.TITLECASE_NO_LOWERCASE | UCharacter.TITLECASE_NO_BREAK_ADJUSTMENT); buf.replace(bufstart, buf.length(), firstFieldTitleCase); // depends on control dependency: [if], data = [none] } } // Set the FieldPosition (for the first occurrence only) if (pos.getBeginIndex() == pos.getEndIndex()) { if (pos.getField() == PATTERN_INDEX_TO_DATE_FORMAT_FIELD[patternCharIndex]) { pos.setBeginIndex(beginOffset); // depends on control dependency: [if], data = [none] pos.setEndIndex(beginOffset + buf.length() - bufstart); // depends on control dependency: [if], data = [none] } else if (pos.getFieldAttribute() == PATTERN_INDEX_TO_DATE_FORMAT_ATTRIBUTE[patternCharIndex]) { pos.setBeginIndex(beginOffset); // depends on control dependency: [if], data = [none] pos.setEndIndex(beginOffset + buf.length() - bufstart); // depends on control dependency: [if], data = [none] } } } }
public class class_name { public boolean parse() { state = State.SEARCHING_ANNOTATION; skipEOLs(); JsDocToken token = next(); // Always record that we have a comment. if (jsdocBuilder.shouldParseDocumentation()) { ExtractionInfo blockInfo = extractBlockComment(token); token = blockInfo.token; if (!blockInfo.string.isEmpty()) { jsdocBuilder.recordBlockDescription(blockInfo.string); } } else { if (token != JsDocToken.ANNOTATION && token != JsDocToken.EOC) { // Mark that there was a description, but don't bother marking // what it was. jsdocBuilder.recordBlockDescription(""); } } return parseHelperLoop(token, new ArrayList<ExtendedTypeInfo>()); } }
public class class_name { public boolean parse() { state = State.SEARCHING_ANNOTATION; skipEOLs(); JsDocToken token = next(); // Always record that we have a comment. if (jsdocBuilder.shouldParseDocumentation()) { ExtractionInfo blockInfo = extractBlockComment(token); token = blockInfo.token; // depends on control dependency: [if], data = [none] if (!blockInfo.string.isEmpty()) { jsdocBuilder.recordBlockDescription(blockInfo.string); // depends on control dependency: [if], data = [none] } } else { if (token != JsDocToken.ANNOTATION && token != JsDocToken.EOC) { // Mark that there was a description, but don't bother marking // what it was. jsdocBuilder.recordBlockDescription(""); // depends on control dependency: [if], data = [none] } } return parseHelperLoop(token, new ArrayList<ExtendedTypeInfo>()); } }
public class class_name { public synchronized Record clear(final URI... properties) { final List<URI> propertiesToClear; if (properties == null || properties.length == 0) { propertiesToClear = doGetProperties(); } else { propertiesToClear = Arrays.asList(properties); } for (final URI property : propertiesToClear) { doSet(property, ImmutableSet.<Object>of()); } return this; } }
public class class_name { public synchronized Record clear(final URI... properties) { final List<URI> propertiesToClear; if (properties == null || properties.length == 0) { propertiesToClear = doGetProperties(); // depends on control dependency: [if], data = [none] } else { propertiesToClear = Arrays.asList(properties); // depends on control dependency: [if], data = [(properties] } for (final URI property : propertiesToClear) { doSet(property, ImmutableSet.<Object>of()); // depends on control dependency: [for], data = [property] } return this; } }
public class class_name { public void marshall(DeleteV2LoggingLevelRequest deleteV2LoggingLevelRequest, ProtocolMarshaller protocolMarshaller) { if (deleteV2LoggingLevelRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(deleteV2LoggingLevelRequest.getTargetType(), TARGETTYPE_BINDING); protocolMarshaller.marshall(deleteV2LoggingLevelRequest.getTargetName(), TARGETNAME_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } } }
public class class_name { public void marshall(DeleteV2LoggingLevelRequest deleteV2LoggingLevelRequest, ProtocolMarshaller protocolMarshaller) { if (deleteV2LoggingLevelRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(deleteV2LoggingLevelRequest.getTargetType(), TARGETTYPE_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(deleteV2LoggingLevelRequest.getTargetName(), TARGETNAME_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 void addDeclaredMethodsFromInterfaces(ClassNode cNode, Map<String, MethodNode> methodsMap) { // add in unimplemented abstract methods from the interfaces for (ClassNode iface : cNode.getInterfaces()) { Map<String, MethodNode> ifaceMethodsMap = iface.getDeclaredMethodsMap(); for (Map.Entry<String, MethodNode> entry : ifaceMethodsMap.entrySet()) { String methSig = entry.getKey(); if (!methodsMap.containsKey(methSig)) { methodsMap.put(methSig, entry.getValue()); } } } } }
public class class_name { public static void addDeclaredMethodsFromInterfaces(ClassNode cNode, Map<String, MethodNode> methodsMap) { // add in unimplemented abstract methods from the interfaces for (ClassNode iface : cNode.getInterfaces()) { Map<String, MethodNode> ifaceMethodsMap = iface.getDeclaredMethodsMap(); for (Map.Entry<String, MethodNode> entry : ifaceMethodsMap.entrySet()) { String methSig = entry.getKey(); if (!methodsMap.containsKey(methSig)) { methodsMap.put(methSig, entry.getValue()); // depends on control dependency: [if], data = [none] } } } } }
public class class_name { public PagedList<CloudPool> list(final PoolListOptions poolListOptions) { ServiceResponseWithHeaders<Page<CloudPool>, PoolListHeaders> response = listSinglePageAsync(poolListOptions).toBlocking().single(); return new PagedList<CloudPool>(response.body()) { @Override public Page<CloudPool> nextPage(String nextPageLink) { PoolListNextOptions poolListNextOptions = null; if (poolListOptions != null) { poolListNextOptions = new PoolListNextOptions(); poolListNextOptions.withClientRequestId(poolListOptions.clientRequestId()); poolListNextOptions.withReturnClientRequestId(poolListOptions.returnClientRequestId()); poolListNextOptions.withOcpDate(poolListOptions.ocpDate()); } return listNextSinglePageAsync(nextPageLink, poolListNextOptions).toBlocking().single().body(); } }; } }
public class class_name { public PagedList<CloudPool> list(final PoolListOptions poolListOptions) { ServiceResponseWithHeaders<Page<CloudPool>, PoolListHeaders> response = listSinglePageAsync(poolListOptions).toBlocking().single(); return new PagedList<CloudPool>(response.body()) { @Override public Page<CloudPool> nextPage(String nextPageLink) { PoolListNextOptions poolListNextOptions = null; if (poolListOptions != null) { poolListNextOptions = new PoolListNextOptions(); // depends on control dependency: [if], data = [none] poolListNextOptions.withClientRequestId(poolListOptions.clientRequestId()); // depends on control dependency: [if], data = [(poolListOptions] poolListNextOptions.withReturnClientRequestId(poolListOptions.returnClientRequestId()); // depends on control dependency: [if], data = [(poolListOptions] poolListNextOptions.withOcpDate(poolListOptions.ocpDate()); // depends on control dependency: [if], data = [(poolListOptions] } return listNextSinglePageAsync(nextPageLink, poolListNextOptions).toBlocking().single().body(); } }; } }
public class class_name { @Override public void setPassword(final String password) { if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) { SibTr.debug(this, TRACE, "setPassword", "***"); } _password = password; } }
public class class_name { @Override public void setPassword(final String password) { if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) { SibTr.debug(this, TRACE, "setPassword", "***"); // depends on control dependency: [if], data = [none] } _password = password; } }
public class class_name { protected TokenList.Token createFunction( TokenList.Token name , List<TokenList.Token> inputs , TokenList tokens , Sequence sequence ) { Operation.Info info; if( inputs.size() == 1 ) info = functions.create(name.getFunction().getName(),inputs.get(0).getVariable()); else { List<Variable> vars = new ArrayList<Variable>(); for (int i = 0; i < inputs.size(); i++) { vars.add(inputs.get(i).getVariable()); } info = functions.create(name.getFunction().getName(), vars ); } sequence.addOperation(info.op); // replace the symbols with the function's output TokenList.Token t = new TokenList.Token(info.output); tokens.replace(name, t); return t; } }
public class class_name { protected TokenList.Token createFunction( TokenList.Token name , List<TokenList.Token> inputs , TokenList tokens , Sequence sequence ) { Operation.Info info; if( inputs.size() == 1 ) info = functions.create(name.getFunction().getName(),inputs.get(0).getVariable()); else { List<Variable> vars = new ArrayList<Variable>(); for (int i = 0; i < inputs.size(); i++) { vars.add(inputs.get(i).getVariable()); // depends on control dependency: [for], data = [i] } info = functions.create(name.getFunction().getName(), vars ); // depends on control dependency: [if], data = [none] } sequence.addOperation(info.op); // replace the symbols with the function's output TokenList.Token t = new TokenList.Token(info.output); tokens.replace(name, t); return t; } }
public class class_name { public void associate() { // initialize data structures matches.reset(); unassociatedSrc.reset(); if( srcPositive.size == 0 && srcNegative.size == 0 ) return; if( dstPositive.size == 0 && dstNegative.size == 0 ) return; // find and add the matches assoc.setSource((FastQueue)srcPositive); assoc.setDestination((FastQueue) dstPositive); assoc.associate(); FastQueue<AssociatedIndex> m = assoc.getMatches(); for( int i = 0; i < m.size; i++ ) { AssociatedIndex a = m.data[i]; int globalSrcIndex = srcPositive.data[a.src].index; int globalDstIndex = dstPositive.data[a.dst].index; matches.grow().setAssociation(globalSrcIndex,globalDstIndex,a.fitScore); } GrowQueue_I32 un = assoc.getUnassociatedSource(); for( int i = 0; i < un.size; i++ ) { unassociatedSrc.add(srcPositive.data[un.get(i)].index); } assoc.setSource((FastQueue)srcNegative); assoc.setDestination((FastQueue) dstNegative); assoc.associate(); m = assoc.getMatches(); for( int i = 0; i < m.size; i++ ) { AssociatedIndex a = m.data[i]; int globalSrcIndex = srcNegative.data[a.src].index; int globalDstIndex = dstNegative.data[a.dst].index; matches.grow().setAssociation(globalSrcIndex,globalDstIndex,a.fitScore); } un = assoc.getUnassociatedSource(); for( int i = 0; i < un.size; i++ ) { unassociatedSrc.add(srcNegative.data[un.get(i)].index); } } }
public class class_name { public void associate() { // initialize data structures matches.reset(); unassociatedSrc.reset(); if( srcPositive.size == 0 && srcNegative.size == 0 ) return; if( dstPositive.size == 0 && dstNegative.size == 0 ) return; // find and add the matches assoc.setSource((FastQueue)srcPositive); assoc.setDestination((FastQueue) dstPositive); assoc.associate(); FastQueue<AssociatedIndex> m = assoc.getMatches(); for( int i = 0; i < m.size; i++ ) { AssociatedIndex a = m.data[i]; int globalSrcIndex = srcPositive.data[a.src].index; int globalDstIndex = dstPositive.data[a.dst].index; matches.grow().setAssociation(globalSrcIndex,globalDstIndex,a.fitScore); // depends on control dependency: [for], data = [none] } GrowQueue_I32 un = assoc.getUnassociatedSource(); for( int i = 0; i < un.size; i++ ) { unassociatedSrc.add(srcPositive.data[un.get(i)].index); // depends on control dependency: [for], data = [i] } assoc.setSource((FastQueue)srcNegative); assoc.setDestination((FastQueue) dstNegative); assoc.associate(); m = assoc.getMatches(); for( int i = 0; i < m.size; i++ ) { AssociatedIndex a = m.data[i]; int globalSrcIndex = srcNegative.data[a.src].index; int globalDstIndex = dstNegative.data[a.dst].index; matches.grow().setAssociation(globalSrcIndex,globalDstIndex,a.fitScore); // depends on control dependency: [for], data = [none] } un = assoc.getUnassociatedSource(); for( int i = 0; i < un.size; i++ ) { unassociatedSrc.add(srcNegative.data[un.get(i)].index); // depends on control dependency: [for], data = [i] } } }
public class class_name { @UiThread public int getParentAdapterPosition() { int flatPosition = getAdapterPosition(); if (mExpandableAdapter == null || flatPosition == RecyclerView.NO_POSITION) { return RecyclerView.NO_POSITION; } return mExpandableAdapter.getNearestParentPosition(flatPosition); } }
public class class_name { @UiThread public int getParentAdapterPosition() { int flatPosition = getAdapterPosition(); if (mExpandableAdapter == null || flatPosition == RecyclerView.NO_POSITION) { return RecyclerView.NO_POSITION; // depends on control dependency: [if], data = [none] } return mExpandableAdapter.getNearestParentPosition(flatPosition); } }
public class class_name { public void setKeyPhrasesDetectionJobPropertiesList(java.util.Collection<KeyPhrasesDetectionJobProperties> keyPhrasesDetectionJobPropertiesList) { if (keyPhrasesDetectionJobPropertiesList == null) { this.keyPhrasesDetectionJobPropertiesList = null; return; } this.keyPhrasesDetectionJobPropertiesList = new java.util.ArrayList<KeyPhrasesDetectionJobProperties>(keyPhrasesDetectionJobPropertiesList); } }
public class class_name { public void setKeyPhrasesDetectionJobPropertiesList(java.util.Collection<KeyPhrasesDetectionJobProperties> keyPhrasesDetectionJobPropertiesList) { if (keyPhrasesDetectionJobPropertiesList == null) { this.keyPhrasesDetectionJobPropertiesList = null; // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } this.keyPhrasesDetectionJobPropertiesList = new java.util.ArrayList<KeyPhrasesDetectionJobProperties>(keyPhrasesDetectionJobPropertiesList); } }
public class class_name { @Override public CPDefinitionInventory fetchByCPDefinitionId(long CPDefinitionId, boolean retrieveFromCache) { Object[] finderArgs = new Object[] { CPDefinitionId }; Object result = null; if (retrieveFromCache) { result = finderCache.getResult(FINDER_PATH_FETCH_BY_CPDEFINITIONID, finderArgs, this); } if (result instanceof CPDefinitionInventory) { CPDefinitionInventory cpDefinitionInventory = (CPDefinitionInventory)result; if ((CPDefinitionId != cpDefinitionInventory.getCPDefinitionId())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(3); query.append(_SQL_SELECT_CPDEFINITIONINVENTORY_WHERE); query.append(_FINDER_COLUMN_CPDEFINITIONID_CPDEFINITIONID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(CPDefinitionId); List<CPDefinitionInventory> list = q.list(); if (list.isEmpty()) { finderCache.putResult(FINDER_PATH_FETCH_BY_CPDEFINITIONID, finderArgs, list); } else { CPDefinitionInventory cpDefinitionInventory = list.get(0); result = cpDefinitionInventory; cacheResult(cpDefinitionInventory); } } catch (Exception e) { finderCache.removeResult(FINDER_PATH_FETCH_BY_CPDEFINITIONID, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (CPDefinitionInventory)result; } } }
public class class_name { @Override public CPDefinitionInventory fetchByCPDefinitionId(long CPDefinitionId, boolean retrieveFromCache) { Object[] finderArgs = new Object[] { CPDefinitionId }; Object result = null; if (retrieveFromCache) { result = finderCache.getResult(FINDER_PATH_FETCH_BY_CPDEFINITIONID, finderArgs, this); // depends on control dependency: [if], data = [none] } if (result instanceof CPDefinitionInventory) { CPDefinitionInventory cpDefinitionInventory = (CPDefinitionInventory)result; if ((CPDefinitionId != cpDefinitionInventory.getCPDefinitionId())) { result = null; // depends on control dependency: [if], data = [none] } } if (result == null) { StringBundler query = new StringBundler(3); query.append(_SQL_SELECT_CPDEFINITIONINVENTORY_WHERE); // depends on control dependency: [if], data = [none] query.append(_FINDER_COLUMN_CPDEFINITIONID_CPDEFINITIONID_2); // depends on control dependency: [if], data = [none] String sql = query.toString(); Session session = null; try { session = openSession(); // depends on control dependency: [try], data = [none] Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(CPDefinitionId); // depends on control dependency: [try], data = [none] List<CPDefinitionInventory> list = q.list(); if (list.isEmpty()) { finderCache.putResult(FINDER_PATH_FETCH_BY_CPDEFINITIONID, finderArgs, list); // depends on control dependency: [if], data = [none] } else { CPDefinitionInventory cpDefinitionInventory = list.get(0); result = cpDefinitionInventory; // depends on control dependency: [if], data = [none] cacheResult(cpDefinitionInventory); // depends on control dependency: [if], data = [none] } } catch (Exception e) { finderCache.removeResult(FINDER_PATH_FETCH_BY_CPDEFINITIONID, finderArgs); throw processException(e); } // depends on control dependency: [catch], data = [none] finally { closeSession(session); } } if (result instanceof List<?>) { return null; // depends on control dependency: [if], data = [none] } else { return (CPDefinitionInventory)result; // depends on control dependency: [if], data = [)] } } }
public class class_name { public T headerFragment(Object model, String mapperName) { Assert.notNull(applicationContext, "Citrus application context is not initialized!"); if (applicationContext.containsBean(mapperName)) { Object mapper = applicationContext.getBean(mapperName); if (Marshaller.class.isAssignableFrom(mapper.getClass())) { return headerFragment(model, (Marshaller) mapper); } else if (ObjectMapper.class.isAssignableFrom(mapper.getClass())) { return headerFragment(model, (ObjectMapper) mapper); } else { throw new CitrusRuntimeException(String.format("Invalid bean type for mapper '%s' expected ObjectMapper or Marshaller but was '%s'", mapperName, mapper.getClass())); } } throw new CitrusRuntimeException("Unable to find default object mapper or marshaller in application context"); } }
public class class_name { public T headerFragment(Object model, String mapperName) { Assert.notNull(applicationContext, "Citrus application context is not initialized!"); if (applicationContext.containsBean(mapperName)) { Object mapper = applicationContext.getBean(mapperName); if (Marshaller.class.isAssignableFrom(mapper.getClass())) { return headerFragment(model, (Marshaller) mapper); // depends on control dependency: [if], data = [none] } else if (ObjectMapper.class.isAssignableFrom(mapper.getClass())) { return headerFragment(model, (ObjectMapper) mapper); // depends on control dependency: [if], data = [none] } else { throw new CitrusRuntimeException(String.format("Invalid bean type for mapper '%s' expected ObjectMapper or Marshaller but was '%s'", mapperName, mapper.getClass())); } } throw new CitrusRuntimeException("Unable to find default object mapper or marshaller in application context"); } }
public class class_name { private String getRootPath(String path, int rootLevel, ResourceResolver resourceResolver) { String rootPath = Path.getAbsoluteParent(path, rootLevel, resourceResolver); // strip off everything after first "." - root path may be passed with selectors/extension which is not relevant if (StringUtils.contains(rootPath, ".")) { rootPath = StringUtils.substringBefore(rootPath, "."); } return rootPath; } }
public class class_name { private String getRootPath(String path, int rootLevel, ResourceResolver resourceResolver) { String rootPath = Path.getAbsoluteParent(path, rootLevel, resourceResolver); // strip off everything after first "." - root path may be passed with selectors/extension which is not relevant if (StringUtils.contains(rootPath, ".")) { rootPath = StringUtils.substringBefore(rootPath, "."); // depends on control dependency: [if], data = [none] } return rootPath; } }
public class class_name { @Override public void eventOccurred(AbstractTaskEvent event) { if (event instanceof TerminationEvent) { terminationSignaled = true; } else if (event instanceof AllWorkersDoneEvent) { AllWorkersDoneEvent wde = (AllWorkersDoneEvent) event; aggregatorNames = wde.getAggregatorNames(); aggregates = wde.getAggregates(userCodeClassLoader); } else { throw new IllegalArgumentException("Unknown event type."); } latch.countDown(); } }
public class class_name { @Override public void eventOccurred(AbstractTaskEvent event) { if (event instanceof TerminationEvent) { terminationSignaled = true; // depends on control dependency: [if], data = [none] } else if (event instanceof AllWorkersDoneEvent) { AllWorkersDoneEvent wde = (AllWorkersDoneEvent) event; aggregatorNames = wde.getAggregatorNames(); // depends on control dependency: [if], data = [none] aggregates = wde.getAggregates(userCodeClassLoader); // depends on control dependency: [if], data = [none] } else { throw new IllegalArgumentException("Unknown event type."); } latch.countDown(); } }
public class class_name { public Observable<ServiceResponse<Page<KeyItem>>> getKeysNextWithServiceResponseAsync(final String nextPageLink) { return getKeysNextSinglePageAsync(nextPageLink) .concatMap(new Func1<ServiceResponse<Page<KeyItem>>, Observable<ServiceResponse<Page<KeyItem>>>>() { @Override public Observable<ServiceResponse<Page<KeyItem>>> call(ServiceResponse<Page<KeyItem>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(getKeysNextWithServiceResponseAsync(nextPageLink)); } }); } }
public class class_name { public Observable<ServiceResponse<Page<KeyItem>>> getKeysNextWithServiceResponseAsync(final String nextPageLink) { return getKeysNextSinglePageAsync(nextPageLink) .concatMap(new Func1<ServiceResponse<Page<KeyItem>>, Observable<ServiceResponse<Page<KeyItem>>>>() { @Override public Observable<ServiceResponse<Page<KeyItem>>> call(ServiceResponse<Page<KeyItem>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); // depends on control dependency: [if], data = [none] } return Observable.just(page).concatWith(getKeysNextWithServiceResponseAsync(nextPageLink)); } }); } }
public class class_name { private Optional<ImmutableSubstitution<ImmutableTerm>> unifyPairs(ImmutableList<TermPair> originalPairs) { /* * Some pairs will be removed, some others will be added. */ List<TermPair> allPairs = new LinkedList<>(originalPairs); Queue<TermPair> pairsToVisit = new LinkedList<>(originalPairs); try { /* * TODO: explain */ while (!pairsToVisit.isEmpty()) { TermPair currentPair = pairsToVisit.poll(); if (currentPair.canBeRemoved()) { continue; } ImmutableSubstitution<ImmutableTerm> substitution = currentPair.getSubstitution(); List<TermPair> additionalPairs = new ArrayList<>(); /* * TODO: explain */ Iterator<TermPair> it = allPairs.iterator(); while (it.hasNext()) { TermPair pairToUpdate = it.next(); if (pairToUpdate == currentPair) { continue; } else { additionalPairs.addAll(pairToUpdate.applySubstitution(substitution)); if (pairToUpdate.canBeRemoved()) { it.remove(); } } } allPairs.addAll(additionalPairs); pairsToVisit.addAll(additionalPairs); } return Optional.of(convertPairs2Substitution(allPairs)); } catch (UnificationException e) { return Optional.empty(); } } }
public class class_name { private Optional<ImmutableSubstitution<ImmutableTerm>> unifyPairs(ImmutableList<TermPair> originalPairs) { /* * Some pairs will be removed, some others will be added. */ List<TermPair> allPairs = new LinkedList<>(originalPairs); Queue<TermPair> pairsToVisit = new LinkedList<>(originalPairs); try { /* * TODO: explain */ while (!pairsToVisit.isEmpty()) { TermPair currentPair = pairsToVisit.poll(); if (currentPair.canBeRemoved()) { continue; } ImmutableSubstitution<ImmutableTerm> substitution = currentPair.getSubstitution(); List<TermPair> additionalPairs = new ArrayList<>(); /* * TODO: explain */ Iterator<TermPair> it = allPairs.iterator(); while (it.hasNext()) { TermPair pairToUpdate = it.next(); if (pairToUpdate == currentPair) { continue; } else { additionalPairs.addAll(pairToUpdate.applySubstitution(substitution)); // depends on control dependency: [if], data = [(pairToUpdate] if (pairToUpdate.canBeRemoved()) { it.remove(); // depends on control dependency: [if], data = [none] } } } allPairs.addAll(additionalPairs); // depends on control dependency: [while], data = [none] pairsToVisit.addAll(additionalPairs); // depends on control dependency: [while], data = [none] } return Optional.of(convertPairs2Substitution(allPairs)); // depends on control dependency: [try], data = [none] } catch (UnificationException e) { return Optional.empty(); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public static String format(Date date, String... patterns) { if (date == null) return ""; String pattern = TIMESTAMP_PATTERN; if (patterns != null && patterns.length > 0 && StringUtils.isNotBlank(patterns[0])) { pattern = patterns[0]; } return DateFormatUtils.format(date, pattern); } }
public class class_name { public static String format(Date date, String... patterns) { if (date == null) return ""; String pattern = TIMESTAMP_PATTERN; if (patterns != null && patterns.length > 0 && StringUtils.isNotBlank(patterns[0])) { pattern = patterns[0]; // depends on control dependency: [if], data = [none] } return DateFormatUtils.format(date, pattern); } }
public class class_name { public boolean addAllValues(MultiMap<V> map) { boolean merged = false; if ((map == null) || (map.isEmpty())) { // done return merged; } for (Map.Entry<String, List<V>> entry : map.entrySet()) { String name = entry.getKey(); List<V> values = entry.getValue(); if (this.containsKey(name)) { merged = true; } this.addValues(name, values); } return merged; } }
public class class_name { public boolean addAllValues(MultiMap<V> map) { boolean merged = false; if ((map == null) || (map.isEmpty())) { // done return merged; // depends on control dependency: [if], data = [none] } for (Map.Entry<String, List<V>> entry : map.entrySet()) { String name = entry.getKey(); List<V> values = entry.getValue(); if (this.containsKey(name)) { merged = true; // depends on control dependency: [if], data = [none] } this.addValues(name, values); // depends on control dependency: [for], data = [none] } return merged; } }
public class class_name { public static void parseBinaryAndUnaryRules(Iterable<String> unfilteredRuleLines, List<CcgBinaryRule> binaryRules, List<CcgUnaryRule> unaryRules) { for (String line : unfilteredRuleLines) { // System.out.println(line); if (!line.startsWith("#")) { try { binaryRules.add(CcgBinaryRule.parseFrom(line)); } catch (IllegalArgumentException e) { unaryRules.add(CcgUnaryRule.parseFrom(line)); } } } } }
public class class_name { public static void parseBinaryAndUnaryRules(Iterable<String> unfilteredRuleLines, List<CcgBinaryRule> binaryRules, List<CcgUnaryRule> unaryRules) { for (String line : unfilteredRuleLines) { // System.out.println(line); if (!line.startsWith("#")) { try { binaryRules.add(CcgBinaryRule.parseFrom(line)); // depends on control dependency: [try], data = [none] } catch (IllegalArgumentException e) { unaryRules.add(CcgUnaryRule.parseFrom(line)); } // depends on control dependency: [catch], data = [none] } } } }
public class class_name { public static int count(SegmentedAdvancedLoadWriteStore<?, ?> salws, IntSet segments) { Long result = Flowable.fromPublisher(salws.publishKeys(segments, null)).count().blockingGet(); if (result > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return result.intValue(); } }
public class class_name { public static int count(SegmentedAdvancedLoadWriteStore<?, ?> salws, IntSet segments) { Long result = Flowable.fromPublisher(salws.publishKeys(segments, null)).count().blockingGet(); if (result > Integer.MAX_VALUE) { return Integer.MAX_VALUE; // depends on control dependency: [if], data = [none] } return result.intValue(); } }
public class class_name { @Override public final void updateThroughput(long currentTime, boolean force) { int interval = (int) (currentTime - lastThroughputCalculationTime); long minInterval = getConfig().getThroughputCalculationIntervalInMillis(); if (minInterval == 0 || interval < minInterval) { if (!force) { return; } } readBytesThroughput = (readBytes - lastReadBytes) * 1000.0 / interval; writtenBytesThroughput = (writtenBytes - lastWrittenBytes) * 1000.0 / interval; readMessagesThroughput = (readMessages - lastReadMessages) * 1000.0 / interval; lastReadBytes = readBytes; lastWrittenBytes = writtenBytes; lastReadMessages = readMessages; lastThroughputCalculationTime = currentTime; } }
public class class_name { @Override public final void updateThroughput(long currentTime, boolean force) { int interval = (int) (currentTime - lastThroughputCalculationTime); long minInterval = getConfig().getThroughputCalculationIntervalInMillis(); if (minInterval == 0 || interval < minInterval) { if (!force) { return; // depends on control dependency: [if], data = [none] } } readBytesThroughput = (readBytes - lastReadBytes) * 1000.0 / interval; writtenBytesThroughput = (writtenBytes - lastWrittenBytes) * 1000.0 / interval; readMessagesThroughput = (readMessages - lastReadMessages) * 1000.0 / interval; lastReadBytes = readBytes; lastWrittenBytes = writtenBytes; lastReadMessages = readMessages; lastThroughputCalculationTime = currentTime; } }
public class class_name { public Font getFont(String fontname, String encoding, boolean embedded, float size, int style, Color color, boolean cached) { if (fontname == null) return new Font(Font.UNDEFINED, size, style, color); String lowercasefontname = fontname.toLowerCase(); ArrayList tmp = (ArrayList) fontFamilies.get(lowercasefontname); if (tmp != null) { // some bugs were fixed here by Daniel Marczisovszky int s = style == Font.UNDEFINED ? Font.NORMAL : style; int fs = Font.NORMAL; boolean found = false; for (Iterator i = tmp.iterator(); i.hasNext(); ) { String f = (String) i.next(); String lcf = f.toLowerCase(); fs = Font.NORMAL; if (lcf.toLowerCase().indexOf("bold") != -1) fs |= Font.BOLD; if (lcf.toLowerCase().indexOf("italic") != -1 || lcf.toLowerCase().indexOf("oblique") != -1) fs |= Font.ITALIC; if ((s & Font.BOLDITALIC) == fs) { fontname = f; found = true; break; } } if (style != Font.UNDEFINED && found) { style &= ~fs; } } BaseFont basefont = null; try { try { // the font is a type 1 font or CJK font basefont = BaseFont.createFont(fontname, encoding, embedded, cached, null, null, true); } catch(DocumentException de) { } if (basefont == null) { // the font is a true type font or an unknown font fontname = trueTypeFonts.getProperty(fontname.toLowerCase()); // the font is not registered as truetype font if (fontname == null) return new Font(Font.UNDEFINED, size, style, color); // the font is registered as truetype font basefont = BaseFont.createFont(fontname, encoding, embedded, cached, null, null); } } catch(DocumentException de) { // this shouldn't happen throw new ExceptionConverter(de); } catch(IOException ioe) { // the font is registered as a true type font, but the path was wrong return new Font(Font.UNDEFINED, size, style, color); } catch(NullPointerException npe) { // null was entered as fontname and/or encoding return new Font(Font.UNDEFINED, size, style, color); } return new Font(basefont, size, style, color); } }
public class class_name { public Font getFont(String fontname, String encoding, boolean embedded, float size, int style, Color color, boolean cached) { if (fontname == null) return new Font(Font.UNDEFINED, size, style, color); String lowercasefontname = fontname.toLowerCase(); ArrayList tmp = (ArrayList) fontFamilies.get(lowercasefontname); if (tmp != null) { // some bugs were fixed here by Daniel Marczisovszky int s = style == Font.UNDEFINED ? Font.NORMAL : style; int fs = Font.NORMAL; boolean found = false; for (Iterator i = tmp.iterator(); i.hasNext(); ) { String f = (String) i.next(); String lcf = f.toLowerCase(); fs = Font.NORMAL; // depends on control dependency: [for], data = [none] if (lcf.toLowerCase().indexOf("bold") != -1) fs |= Font.BOLD; if (lcf.toLowerCase().indexOf("italic") != -1 || lcf.toLowerCase().indexOf("oblique") != -1) fs |= Font.ITALIC; if ((s & Font.BOLDITALIC) == fs) { fontname = f; // depends on control dependency: [if], data = [none] found = true; // depends on control dependency: [if], data = [none] break; } } if (style != Font.UNDEFINED && found) { style &= ~fs; // depends on control dependency: [if], data = [none] } } BaseFont basefont = null; try { try { // the font is a type 1 font or CJK font basefont = BaseFont.createFont(fontname, encoding, embedded, cached, null, null, true); // depends on control dependency: [try], data = [none] } catch(DocumentException de) { } // depends on control dependency: [catch], data = [none] if (basefont == null) { // the font is a true type font or an unknown font fontname = trueTypeFonts.getProperty(fontname.toLowerCase()); // depends on control dependency: [if], data = [none] // the font is not registered as truetype font if (fontname == null) return new Font(Font.UNDEFINED, size, style, color); // the font is registered as truetype font basefont = BaseFont.createFont(fontname, encoding, embedded, cached, null, null); // depends on control dependency: [if], data = [null)] } } catch(DocumentException de) { // this shouldn't happen throw new ExceptionConverter(de); } // depends on control dependency: [catch], data = [none] catch(IOException ioe) { // the font is registered as a true type font, but the path was wrong return new Font(Font.UNDEFINED, size, style, color); } // depends on control dependency: [catch], data = [none] catch(NullPointerException npe) { // null was entered as fontname and/or encoding return new Font(Font.UNDEFINED, size, style, color); } // depends on control dependency: [catch], data = [none] return new Font(basefont, size, style, color); } }
public class class_name { private boolean attributeEquals(Object value, Object otherValue) { if (value == null && otherValue == null) { return true; } else if (value == null || otherValue == null) { return false; } else { if (value.getClass().isArray()) { return Arrays.equals((Object[]) value, (Object[]) otherValue); } else { return value.equals(otherValue); } } } }
public class class_name { private boolean attributeEquals(Object value, Object otherValue) { if (value == null && otherValue == null) { return true; // depends on control dependency: [if], data = [none] } else if (value == null || otherValue == null) { return false; // depends on control dependency: [if], data = [none] } else { if (value.getClass().isArray()) { return Arrays.equals((Object[]) value, (Object[]) otherValue); // depends on control dependency: [if], data = [none] } else { return value.equals(otherValue); // depends on control dependency: [if], data = [none] } } } }
public class class_name { private boolean skipBlankAndComma() { boolean commaFound = false; while (!isEOS()) { int c = str.charAt(idx); if (c == ',') { if (commaFound) return true; else commaFound = true; } else if (!isBlank(c)) { return true; } ++idx; } return false; } }
public class class_name { private boolean skipBlankAndComma() { boolean commaFound = false; while (!isEOS()) { int c = str.charAt(idx); if (c == ',') { if (commaFound) return true; else commaFound = true; } else if (!isBlank(c)) { return true; // depends on control dependency: [if], data = [none] } ++idx; // depends on control dependency: [while], data = [none] } return false; } }
public class class_name { public void dump(String msg) { StringBuffer pond=new StringBuffer(); StringBuffer avail=new StringBuffer(); StringBuffer index=new StringBuffer(); pond.append("pond: "); avail.append("avail:"); index.append("index:"); for (int i=0;i<_pondLife.length;i++) { if (_pondLife[i]==null) pond.append(" "); else { pond.append(' '); StringUtil.append(pond,(byte)i,16); } if (i==_size) avail.append(i==_available?" AS":" S"); else avail.append(i==_available?" A ":" "); index.append(' '); StringUtil.append(index,(byte)_index[i],16); } System.err.println(); System.err.println(msg); System.err.println(pond); System.err.println(avail); System.err.println(index); } }
public class class_name { public void dump(String msg) { StringBuffer pond=new StringBuffer(); StringBuffer avail=new StringBuffer(); StringBuffer index=new StringBuffer(); pond.append("pond: "); avail.append("avail:"); index.append("index:"); for (int i=0;i<_pondLife.length;i++) { if (_pondLife[i]==null) pond.append(" "); else { pond.append(' '); // depends on control dependency: [if], data = [none] StringUtil.append(pond,(byte)i,16); // depends on control dependency: [if], data = [none] } if (i==_size) avail.append(i==_available?" AS":" S"); else avail.append(i==_available?" A ":" "); index.append(' '); // depends on control dependency: [for], data = [none] StringUtil.append(index,(byte)_index[i],16); // depends on control dependency: [for], data = [i] } System.err.println(); System.err.println(msg); System.err.println(pond); System.err.println(avail); System.err.println(index); } }
public class class_name { public static InputStream getResourceAsStream(String name) { InputStream stream = null; try { stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); } catch (SecurityException e) { LOG.info("Unable to access context classloader, using default. " + e.getMessage()); } if (stream == null) { stream = ResourceLoader.class.getResourceAsStream("/" + name); } return stream; } }
public class class_name { public static InputStream getResourceAsStream(String name) { InputStream stream = null; try { stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); // depends on control dependency: [try], data = [none] } catch (SecurityException e) { LOG.info("Unable to access context classloader, using default. " + e.getMessage()); } // depends on control dependency: [catch], data = [none] if (stream == null) { stream = ResourceLoader.class.getResourceAsStream("/" + name); // depends on control dependency: [if], data = [none] } return stream; } }
public class class_name { private void fireOnCancelBasic(ChannelEvent e) { List<EventListener> listeners = changes.getListenerList(AMQP); for (EventListener listener : listeners) { ChannelListener amqpListener = (ChannelListener)listener; amqpListener.onCancelBasic(e); } } }
public class class_name { private void fireOnCancelBasic(ChannelEvent e) { List<EventListener> listeners = changes.getListenerList(AMQP); for (EventListener listener : listeners) { ChannelListener amqpListener = (ChannelListener)listener; amqpListener.onCancelBasic(e); // depends on control dependency: [for], data = [none] } } }
public class class_name { private Object getEnumValue(Class<?> type, Object value) { Object[] enumValues = type.getEnumConstants(); for (Object enumValue : enumValues) { if (enumValue.toString().equals(value.toString())) { value = enumValue; break; } } return value; } }
public class class_name { private Object getEnumValue(Class<?> type, Object value) { Object[] enumValues = type.getEnumConstants(); for (Object enumValue : enumValues) { if (enumValue.toString().equals(value.toString())) { value = enumValue; // depends on control dependency: [if], data = [none] break; } } return value; } }
public class class_name { public static String getColumnIndexFromSaveAttr(final String saveAttr) { if ((saveAttr != null) && (!saveAttr.isEmpty())) { int iend = saveAttr.indexOf('='); if (iend > 0) { int istart = saveAttr.indexOf('$'); if (iend > istart) { return saveAttr.substring(istart + 1, iend); } } } return null; } }
public class class_name { public static String getColumnIndexFromSaveAttr(final String saveAttr) { if ((saveAttr != null) && (!saveAttr.isEmpty())) { int iend = saveAttr.indexOf('='); if (iend > 0) { int istart = saveAttr.indexOf('$'); if (iend > istart) { return saveAttr.substring(istart + 1, iend); // depends on control dependency: [if], data = [none] } } } return null; } }
public class class_name { public void marshall(ProvisioningArtifactProperties provisioningArtifactProperties, ProtocolMarshaller protocolMarshaller) { if (provisioningArtifactProperties == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(provisioningArtifactProperties.getName(), NAME_BINDING); protocolMarshaller.marshall(provisioningArtifactProperties.getDescription(), DESCRIPTION_BINDING); protocolMarshaller.marshall(provisioningArtifactProperties.getInfo(), INFO_BINDING); protocolMarshaller.marshall(provisioningArtifactProperties.getType(), TYPE_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } } }
public class class_name { public void marshall(ProvisioningArtifactProperties provisioningArtifactProperties, ProtocolMarshaller protocolMarshaller) { if (provisioningArtifactProperties == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(provisioningArtifactProperties.getName(), NAME_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(provisioningArtifactProperties.getDescription(), DESCRIPTION_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(provisioningArtifactProperties.getInfo(), INFO_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(provisioningArtifactProperties.getType(), TYPE_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 CharSequence expandTemplate(CharSequence template, CharSequence... values) { if (values.length > 9) { throw new IllegalArgumentException("max of 9 values are supported"); } SpannableStringBuilder ssb = new SpannableStringBuilder(template); try { int i = 0; while (i < ssb.length()) { if (ssb.charAt(i) == '^') { char next = ssb.charAt(i+1); if (next == '^') { ssb.delete(i+1, i+2); ++i; continue; } else if (Character.isDigit(next)) { int which = Character.getNumericValue(next) - 1; if (which < 0) { throw new IllegalArgumentException( "template requests value ^" + (which+1)); } if (which >= values.length) { throw new IllegalArgumentException( "template requests value ^" + (which+1) + "; only " + values.length + " provided"); } ssb.replace(i, i+2, values[which]); i += values[which].length(); continue; } } ++i; } } catch (IndexOutOfBoundsException ignore) { // happens when ^ is the last character in the string. } return ssb; } }
public class class_name { public static CharSequence expandTemplate(CharSequence template, CharSequence... values) { if (values.length > 9) { throw new IllegalArgumentException("max of 9 values are supported"); } SpannableStringBuilder ssb = new SpannableStringBuilder(template); try { int i = 0; while (i < ssb.length()) { if (ssb.charAt(i) == '^') { char next = ssb.charAt(i+1); if (next == '^') { ssb.delete(i+1, i+2); // depends on control dependency: [if], data = [none] ++i; // depends on control dependency: [if], data = [none] continue; } else if (Character.isDigit(next)) { int which = Character.getNumericValue(next) - 1; if (which < 0) { throw new IllegalArgumentException( "template requests value ^" + (which+1)); } if (which >= values.length) { throw new IllegalArgumentException( "template requests value ^" + (which+1) + "; only " + values.length + " provided"); } ssb.replace(i, i+2, values[which]); // depends on control dependency: [if], data = [none] i += values[which].length(); // depends on control dependency: [if], data = [none] continue; } } ++i; // depends on control dependency: [while], data = [none] } } catch (IndexOutOfBoundsException ignore) { // happens when ^ is the last character in the string. } // depends on control dependency: [catch], data = [none] return ssb; } }
public class class_name { @SuppressWarnings("deprecation") private void setLegacyConnectionTimeout(HttpClient client, int timeout) { if (org.apache.http.impl.client.AbstractHttpClient.class.isInstance(client)) { client.getParams().setIntParameter( org.apache.http.params.CoreConnectionPNames.CONNECTION_TIMEOUT, timeout); } } }
public class class_name { @SuppressWarnings("deprecation") private void setLegacyConnectionTimeout(HttpClient client, int timeout) { if (org.apache.http.impl.client.AbstractHttpClient.class.isInstance(client)) { client.getParams().setIntParameter( org.apache.http.params.CoreConnectionPNames.CONNECTION_TIMEOUT, timeout); // depends on control dependency: [if], data = [none] } } }
public class class_name { public void setContainers(java.util.Collection<ContainerDefinition> containers) { if (containers == null) { this.containers = null; return; } this.containers = new java.util.ArrayList<ContainerDefinition>(containers); } }
public class class_name { public void setContainers(java.util.Collection<ContainerDefinition> containers) { if (containers == null) { this.containers = null; // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } this.containers = new java.util.ArrayList<ContainerDefinition>(containers); } }
public class class_name { @NotThreadsafe private void initFileStreams(int chunkId) { /** * {@link Set#add(Object)} returns false if the element already existed in the set. * This ensures we initialize the resources for each chunk only once. */ if (chunksHandled.add(chunkId)) { try { this.indexFileSizeInBytes[chunkId] = 0L; this.valueFileSizeInBytes[chunkId] = 0L; this.checkSumDigestIndex[chunkId] = CheckSum.getInstance(checkSumType); this.checkSumDigestValue[chunkId] = CheckSum.getInstance(checkSumType); this.position[chunkId] = 0; this.taskIndexFileName[chunkId] = new Path(FileOutputFormat.getOutputPath(conf), getStoreName() + "." + Integer.toString(chunkId) + "_" + this.taskId + INDEX_FILE_EXTENSION + fileExtension); this.taskValueFileName[chunkId] = new Path(FileOutputFormat.getOutputPath(conf), getStoreName() + "." + Integer.toString(chunkId) + "_" + this.taskId + DATA_FILE_EXTENSION + fileExtension); if(this.fs == null) this.fs = this.taskIndexFileName[chunkId].getFileSystem(conf); if(isValidCompressionEnabled) { this.indexFileStream[chunkId] = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(fs.create(this.taskIndexFileName[chunkId]), DEFAULT_BUFFER_SIZE))); this.valueFileStream[chunkId] = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(fs.create(this.taskValueFileName[chunkId]), DEFAULT_BUFFER_SIZE))); } else { this.indexFileStream[chunkId] = fs.create(this.taskIndexFileName[chunkId]); this.valueFileStream[chunkId] = fs.create(this.taskValueFileName[chunkId]); } fs.setPermission(this.taskIndexFileName[chunkId], new FsPermission(HadoopStoreBuilder.HADOOP_FILE_PERMISSION)); logger.info("Setting permission to 755 for " + this.taskIndexFileName[chunkId]); fs.setPermission(this.taskValueFileName[chunkId], new FsPermission(HadoopStoreBuilder.HADOOP_FILE_PERMISSION)); logger.info("Setting permission to 755 for " + this.taskValueFileName[chunkId]); logger.info("Opening " + this.taskIndexFileName[chunkId] + " and " + this.taskValueFileName[chunkId] + " for writing."); } catch(IOException e) { throw new RuntimeException("Failed to open Input/OutputStream", e); } } } }
public class class_name { @NotThreadsafe private void initFileStreams(int chunkId) { /** * {@link Set#add(Object)} returns false if the element already existed in the set. * This ensures we initialize the resources for each chunk only once. */ if (chunksHandled.add(chunkId)) { try { this.indexFileSizeInBytes[chunkId] = 0L; // depends on control dependency: [try], data = [none] this.valueFileSizeInBytes[chunkId] = 0L; // depends on control dependency: [try], data = [none] this.checkSumDigestIndex[chunkId] = CheckSum.getInstance(checkSumType); // depends on control dependency: [try], data = [none] this.checkSumDigestValue[chunkId] = CheckSum.getInstance(checkSumType); // depends on control dependency: [try], data = [none] this.position[chunkId] = 0; // depends on control dependency: [try], data = [none] this.taskIndexFileName[chunkId] = new Path(FileOutputFormat.getOutputPath(conf), getStoreName() + "." + Integer.toString(chunkId) + "_" + this.taskId + INDEX_FILE_EXTENSION + fileExtension); // depends on control dependency: [try], data = [none] this.taskValueFileName[chunkId] = new Path(FileOutputFormat.getOutputPath(conf), getStoreName() + "." + Integer.toString(chunkId) + "_" + this.taskId + DATA_FILE_EXTENSION + fileExtension); // depends on control dependency: [try], data = [none] if(this.fs == null) this.fs = this.taskIndexFileName[chunkId].getFileSystem(conf); if(isValidCompressionEnabled) { this.indexFileStream[chunkId] = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(fs.create(this.taskIndexFileName[chunkId]), DEFAULT_BUFFER_SIZE))); // depends on control dependency: [if], data = [none] this.valueFileStream[chunkId] = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(fs.create(this.taskValueFileName[chunkId]), DEFAULT_BUFFER_SIZE))); // depends on control dependency: [if], data = [none] } else { this.indexFileStream[chunkId] = fs.create(this.taskIndexFileName[chunkId]); // depends on control dependency: [if], data = [none] this.valueFileStream[chunkId] = fs.create(this.taskValueFileName[chunkId]); // depends on control dependency: [if], data = [none] } fs.setPermission(this.taskIndexFileName[chunkId], new FsPermission(HadoopStoreBuilder.HADOOP_FILE_PERMISSION)); // depends on control dependency: [try], data = [none] logger.info("Setting permission to 755 for " + this.taskIndexFileName[chunkId]); // depends on control dependency: [try], data = [none] fs.setPermission(this.taskValueFileName[chunkId], new FsPermission(HadoopStoreBuilder.HADOOP_FILE_PERMISSION)); // depends on control dependency: [try], data = [none] logger.info("Setting permission to 755 for " + this.taskValueFileName[chunkId]); // depends on control dependency: [try], data = [none] logger.info("Opening " + this.taskIndexFileName[chunkId] + " and " + this.taskValueFileName[chunkId] + " for writing."); // depends on control dependency: [try], data = [none] } catch(IOException e) { throw new RuntimeException("Failed to open Input/OutputStream", e); } // depends on control dependency: [catch], data = [none] } } }
public class class_name { String getResourceName(String fileName) { // FIXME: there is probably a more robust way to do this // Strip off the directory part. String dirPath = directory.getPath(); if (!fileName.startsWith(dirPath)) { throw new IllegalStateException("Filename " + fileName + " not inside directory " + dirPath); } // The problem here is that we need to take the relative part of the // filename // and break it into components that we can then reconstruct into // a resource name (using '/' characters to separate the components). // Unfortunately, the File class does not make this task particularly // easy. String relativeFileName = fileName.substring(dirPath.length()); File file = new File(relativeFileName); LinkedList<String> partList = new LinkedList<>(); do { partList.addFirst(file.getName()); } while ((file = file.getParentFile()) != null); StringBuilder buf = new StringBuilder(); for (String part : partList) { if (buf.length() > 0) { buf.append('/'); } buf.append(part); } return buf.toString(); } }
public class class_name { String getResourceName(String fileName) { // FIXME: there is probably a more robust way to do this // Strip off the directory part. String dirPath = directory.getPath(); if (!fileName.startsWith(dirPath)) { throw new IllegalStateException("Filename " + fileName + " not inside directory " + dirPath); } // The problem here is that we need to take the relative part of the // filename // and break it into components that we can then reconstruct into // a resource name (using '/' characters to separate the components). // Unfortunately, the File class does not make this task particularly // easy. String relativeFileName = fileName.substring(dirPath.length()); File file = new File(relativeFileName); LinkedList<String> partList = new LinkedList<>(); do { partList.addFirst(file.getName()); } while ((file = file.getParentFile()) != null); StringBuilder buf = new StringBuilder(); for (String part : partList) { if (buf.length() > 0) { buf.append('/'); // depends on control dependency: [if], data = [none] } buf.append(part); // depends on control dependency: [for], data = [part] } return buf.toString(); } }
public class class_name { public void forceRemoveItems() { synchronized (locker) { for (int j = 0; j < downloadQueue.size() - getMaxLoading(); j++) { QueueHolder tmp = downloadQueue.get(j); if (tmp != null) { tmp.stopLoading(); downloadQueue.remove(j); } } } } }
public class class_name { public void forceRemoveItems() { synchronized (locker) { for (int j = 0; j < downloadQueue.size() - getMaxLoading(); j++) { QueueHolder tmp = downloadQueue.get(j); if (tmp != null) { tmp.stopLoading(); // depends on control dependency: [if], data = [none] downloadQueue.remove(j); // depends on control dependency: [if], data = [none] } } } } }
public class class_name { @ConditionBlock public void evaluate(Runnable block) { try { block.run(); } catch (Throwable t) { exceptions.add(t); wakeUp(); } latch.countDown(); } }
public class class_name { @ConditionBlock public void evaluate(Runnable block) { try { block.run(); // depends on control dependency: [try], data = [none] } catch (Throwable t) { exceptions.add(t); wakeUp(); } // depends on control dependency: [catch], data = [none] latch.countDown(); } }
public class class_name { public Observable<ServiceResponse<Page<StampCapacityInner>>> listCapacitiesWithServiceResponseAsync(final String resourceGroupName, final String name) { return listCapacitiesSinglePageAsync(resourceGroupName, name) .concatMap(new Func1<ServiceResponse<Page<StampCapacityInner>>, Observable<ServiceResponse<Page<StampCapacityInner>>>>() { @Override public Observable<ServiceResponse<Page<StampCapacityInner>>> call(ServiceResponse<Page<StampCapacityInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(listCapacitiesNextWithServiceResponseAsync(nextPageLink)); } }); } }
public class class_name { public Observable<ServiceResponse<Page<StampCapacityInner>>> listCapacitiesWithServiceResponseAsync(final String resourceGroupName, final String name) { return listCapacitiesSinglePageAsync(resourceGroupName, name) .concatMap(new Func1<ServiceResponse<Page<StampCapacityInner>>, Observable<ServiceResponse<Page<StampCapacityInner>>>>() { @Override public Observable<ServiceResponse<Page<StampCapacityInner>>> call(ServiceResponse<Page<StampCapacityInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); // depends on control dependency: [if], data = [none] } return Observable.just(page).concatWith(listCapacitiesNextWithServiceResponseAsync(nextPageLink)); } }); } }
public class class_name { public final void removeConsumerKey(String selector, JSRemoteConsumerPoint aock) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "removeConsumerKey", new Object[] { selector, aock }); synchronized (this) { JSRemoteConsumerPoint aock2 = (JSRemoteConsumerPoint) consumerKeyTable.get(selector); if (aock2 == aock) { // the object is still in the table consumerKeyTable.remove(selector); } } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "removeConsumerKey"); } }
public class class_name { public final void removeConsumerKey(String selector, JSRemoteConsumerPoint aock) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "removeConsumerKey", new Object[] { selector, aock }); synchronized (this) { JSRemoteConsumerPoint aock2 = (JSRemoteConsumerPoint) consumerKeyTable.get(selector); if (aock2 == aock) { // the object is still in the table consumerKeyTable.remove(selector); // depends on control dependency: [if], data = [none] } } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "removeConsumerKey"); } }
public class class_name { public EClass getIfcAlarmType() { if (ifcAlarmTypeEClass == null) { ifcAlarmTypeEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc2x3tc1Package.eNS_URI) .getEClassifiers().get(10); } return ifcAlarmTypeEClass; } }
public class class_name { public EClass getIfcAlarmType() { if (ifcAlarmTypeEClass == null) { ifcAlarmTypeEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc2x3tc1Package.eNS_URI) .getEClassifiers().get(10); // depends on control dependency: [if], data = [none] } return ifcAlarmTypeEClass; } }
public class class_name { public static MutableRoaringBitmap naive_and(ImmutableRoaringBitmap... bitmaps) { MutableRoaringBitmap answer; if (bitmaps.length > 0) { answer = (bitmaps[0]).toMutableRoaringBitmap(); for (int k = 1; k < bitmaps.length; ++k) { answer = ImmutableRoaringBitmap.and(answer, bitmaps[k]); } } else { answer = new MutableRoaringBitmap(); } return answer; } }
public class class_name { public static MutableRoaringBitmap naive_and(ImmutableRoaringBitmap... bitmaps) { MutableRoaringBitmap answer; if (bitmaps.length > 0) { answer = (bitmaps[0]).toMutableRoaringBitmap(); // depends on control dependency: [if], data = [none] for (int k = 1; k < bitmaps.length; ++k) { answer = ImmutableRoaringBitmap.and(answer, bitmaps[k]); // depends on control dependency: [for], data = [k] } } else { answer = new MutableRoaringBitmap(); // depends on control dependency: [if], data = [none] } return answer; } }
public class class_name { public static File toFile(final URI filename) { if (filename == null) { return null; } final URI f = stripFragment(filename); if ("file".equals(f.getScheme()) && f.getPath() != null && f.isAbsolute()) { return new File(f); } else { return toFile(f.toString()); } } }
public class class_name { public static File toFile(final URI filename) { if (filename == null) { return null; // depends on control dependency: [if], data = [none] } final URI f = stripFragment(filename); if ("file".equals(f.getScheme()) && f.getPath() != null && f.isAbsolute()) { return new File(f); // depends on control dependency: [if], data = [none] } else { return toFile(f.toString()); // depends on control dependency: [if], data = [none] } } }
public class class_name { public static String format( final String messagePattern, Object arg1, Object arg2 ) { int i = 0; int patternLength = messagePattern.length(); StringBuffer sbuf = new StringBuffer( patternLength + 50 ); for( int L = 0; L < 2; L++ ) { int j = messagePattern.indexOf( DELIM_START, i ); if( j == -1 || ( j + 1 == patternLength ) ) { // no more variables if( i == 0 ) { // this is a simple string return messagePattern; } else { // add the tail string which contains no variables and return the result. sbuf.append( messagePattern.substring( i, patternLength ) ); return sbuf.toString(); } } else { char delimStop = messagePattern.charAt( j + 1 ); if( delimStop != DELIM_STOP ) { // invalid DELIM_START/DELIM_STOP pair sbuf.append( messagePattern.substring( i, patternLength ) ); return sbuf.toString(); } sbuf.append( messagePattern.substring( i, j ) ); if( L == 0 ) { sbuf.append( arg1 ); } else { sbuf.append( arg2 ); } i = j + 2; } } // append the characters following the second {} pair. String remainder = messagePattern.substring( i, patternLength ); sbuf.append( remainder ); return sbuf.toString(); } }
public class class_name { public static String format( final String messagePattern, Object arg1, Object arg2 ) { int i = 0; int patternLength = messagePattern.length(); StringBuffer sbuf = new StringBuffer( patternLength + 50 ); for( int L = 0; L < 2; L++ ) { int j = messagePattern.indexOf( DELIM_START, i ); if( j == -1 || ( j + 1 == patternLength ) ) { // no more variables if( i == 0 ) { // this is a simple string return messagePattern; // depends on control dependency: [if], data = [none] } else { // add the tail string which contains no variables and return the result. sbuf.append( messagePattern.substring( i, patternLength ) ); // depends on control dependency: [if], data = [( i] return sbuf.toString(); // depends on control dependency: [if], data = [none] } } else { char delimStop = messagePattern.charAt( j + 1 ); if( delimStop != DELIM_STOP ) { // invalid DELIM_START/DELIM_STOP pair sbuf.append( messagePattern.substring( i, patternLength ) ); // depends on control dependency: [if], data = [none] return sbuf.toString(); // depends on control dependency: [if], data = [none] } sbuf.append( messagePattern.substring( i, j ) ); // depends on control dependency: [if], data = [none] if( L == 0 ) { sbuf.append( arg1 ); // depends on control dependency: [if], data = [none] } else { sbuf.append( arg2 ); // depends on control dependency: [if], data = [none] } i = j + 2; // depends on control dependency: [if], data = [none] } } // append the characters following the second {} pair. String remainder = messagePattern.substring( i, patternLength ); sbuf.append( remainder ); return sbuf.toString(); } }
public class class_name { static Timer createTimer() { try { return getInstance().doPrivileged(new PrivilegedAction<Timer>() { @Override public Timer run() { return new Timer(true); // 691649 } }); } catch (SecurityException se) { // TODO: Add logging here but be careful since this code is used in logging logic itself // and may result in an indefinite loop. return null; } } }
public class class_name { static Timer createTimer() { try { return getInstance().doPrivileged(new PrivilegedAction<Timer>() { @Override public Timer run() { return new Timer(true); // 691649 } }); // depends on control dependency: [try], data = [none] } catch (SecurityException se) { // TODO: Add logging here but be careful since this code is used in logging logic itself // and may result in an indefinite loop. return null; } // depends on control dependency: [catch], data = [none] } }
public class class_name { public void add(ShapeMarkers shapeMarkers) { for (Marker marker : shapeMarkers.getMarkers()) { add(marker, shapeMarkers); } } }
public class class_name { public void add(ShapeMarkers shapeMarkers) { for (Marker marker : shapeMarkers.getMarkers()) { add(marker, shapeMarkers); // depends on control dependency: [for], data = [marker] } } }
public class class_name { HasName findReference(String fullRefName, String enclosingNamespace) { boolean doneSearch = false; // Special case: if fullRefName begins with a period it is a fully qualified // name so just search for that (but strip off the initial dot!) if (fullRefName.charAt(0) == '.') return findFullyQualifiedObject(fullRefName.substring(1)); // Search for the object in the enclosing namespace, as well as each parent // namespace until we find the object while (!doneSearch) { String searchName = (enclosingNamespace == null ? fullRefName : enclosingNamespace + '.' + fullRefName); HasName obj = findFullyQualifiedObject(searchName); if (obj != null) return obj; // We didn't find the object. Strip off the last component of the // namespace and try again if (enclosingNamespace != null) { int dotIndex = enclosingNamespace.lastIndexOf('.'); if (dotIndex < 0) enclosingNamespace = null; else enclosingNamespace = enclosingNamespace.substring(0, dotIndex); } else { doneSearch = true; } } // If we didn't find a match using the normal protobuf-compatible // lookup method, try searching each imported .proto as if we were // in their namespace for (Proto proto : getImportedProtos()) { String searchName = (proto.getPackageName() == null ? fullRefName : proto.getPackageName() + '.' + fullRefName); HasName result = proto.findFullyQualifiedObject(searchName); if (result != null) return result; } // No results return null; } }
public class class_name { HasName findReference(String fullRefName, String enclosingNamespace) { boolean doneSearch = false; // Special case: if fullRefName begins with a period it is a fully qualified // name so just search for that (but strip off the initial dot!) if (fullRefName.charAt(0) == '.') return findFullyQualifiedObject(fullRefName.substring(1)); // Search for the object in the enclosing namespace, as well as each parent // namespace until we find the object while (!doneSearch) { String searchName = (enclosingNamespace == null ? fullRefName : enclosingNamespace + '.' + fullRefName); HasName obj = findFullyQualifiedObject(searchName); if (obj != null) return obj; // We didn't find the object. Strip off the last component of the // namespace and try again if (enclosingNamespace != null) { int dotIndex = enclosingNamespace.lastIndexOf('.'); if (dotIndex < 0) enclosingNamespace = null; else enclosingNamespace = enclosingNamespace.substring(0, dotIndex); } else { doneSearch = true; // depends on control dependency: [if], data = [none] } } // If we didn't find a match using the normal protobuf-compatible // lookup method, try searching each imported .proto as if we were // in their namespace for (Proto proto : getImportedProtos()) { String searchName = (proto.getPackageName() == null ? fullRefName : proto.getPackageName() + '.' + fullRefName); HasName result = proto.findFullyQualifiedObject(searchName); if (result != null) return result; } // No results return null; } }
public class class_name { public void marshall(SqlApplicationConfigurationDescription sqlApplicationConfigurationDescription, ProtocolMarshaller protocolMarshaller) { if (sqlApplicationConfigurationDescription == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(sqlApplicationConfigurationDescription.getInputDescriptions(), INPUTDESCRIPTIONS_BINDING); protocolMarshaller.marshall(sqlApplicationConfigurationDescription.getOutputDescriptions(), OUTPUTDESCRIPTIONS_BINDING); protocolMarshaller.marshall(sqlApplicationConfigurationDescription.getReferenceDataSourceDescriptions(), REFERENCEDATASOURCEDESCRIPTIONS_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } } }
public class class_name { public void marshall(SqlApplicationConfigurationDescription sqlApplicationConfigurationDescription, ProtocolMarshaller protocolMarshaller) { if (sqlApplicationConfigurationDescription == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(sqlApplicationConfigurationDescription.getInputDescriptions(), INPUTDESCRIPTIONS_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(sqlApplicationConfigurationDescription.getOutputDescriptions(), OUTPUTDESCRIPTIONS_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(sqlApplicationConfigurationDescription.getReferenceDataSourceDescriptions(), REFERENCEDATASOURCEDESCRIPTIONS_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 void gridSearch(Grid<MP> grid) { Model model = null; // Prepare nice model key and override default key by appending model counter //String protoModelKey = _hyperSpaceWalker.getParams()._model_id == null // ? grid._key + "_model_" // : _hyperSpaceWalker.getParams()._model_id.toString() + H2O.calcNextUniqueModelId("") + "_"; String protoModelKey = grid._key + "_model_"; try { // Get iterator to traverse hyper space HyperSpaceWalker.HyperSpaceIterator<MP> it = _hyperSpaceWalker.iterator(); // Number of traversed model parameters int counter = grid.getModelCount(); while (it.hasNext(model)) { if (_job.stop_requested()) throw new Job.JobCancelledException(); // Handle end-user cancel request double max_runtime_secs = it.max_runtime_secs(); double time_remaining_secs = Double.MAX_VALUE; if (max_runtime_secs > 0) { time_remaining_secs = it.time_remaining_secs(); if (time_remaining_secs < 0) { Log.info("Grid max_runtime_secs of " + max_runtime_secs + " secs has expired; stopping early."); throw new Job.JobCancelledException(); } } MP params; try { // Get parameters for next model params = it.nextModelParameters(model); // Sequential model building, should never propagate // exception up, just mark combination of model parameters as wrong // Do we need to limit the model build time? if (max_runtime_secs > 0) { Log.info("Grid time is limited to: " + max_runtime_secs + " for grid: " + grid._key + ". Remaining time is: " + time_remaining_secs); if (params._max_runtime_secs == 0) { // unlimited params._max_runtime_secs = time_remaining_secs; Log.info("Due to the grid time limit, changing model max runtime to: " + params._max_runtime_secs + " secs."); } else { double was = params._max_runtime_secs; params._max_runtime_secs = Math.min(params._max_runtime_secs, time_remaining_secs); Log.info("Due to the grid time limit, changing model max runtime from: " + was + " secs to: " + params._max_runtime_secs + " secs."); } } try { ScoringInfo scoringInfo = new ScoringInfo(); scoringInfo.time_stamp_ms = System.currentTimeMillis(); //// build the model! model = buildModel(params, grid, ++counter, protoModelKey); if (model != null) { model.fillScoringInfo(scoringInfo); grid.setScoringInfos(ScoringInfo.prependScoringInfo(scoringInfo, grid.getScoringInfos())); ScoringInfo.sort(grid.getScoringInfos(), _hyperSpaceWalker.search_criteria().stopping_metric()); // Currently AUTO for Cartesian and user-specified for RandomDiscrete } } catch (RuntimeException e) { // Catch everything if (!Job.isCancelledException(e)) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Log.warn("Grid search: model builder for parameters " + params + " failed! Exception: ", e, sw.toString()); } grid.appendFailedModelParameters(params, e); } } catch (IllegalArgumentException e) { Log.warn("Grid search: construction of model parameters failed! Exception: ", e); // Model parameters cannot be constructed for some reason it.modelFailed(model); Object[] rawParams = it.getCurrentRawParameters(); grid.appendFailedModelParameters(rawParams, e); } finally { // Update progress by 1 increment _job.update(1); // Always update grid in DKV after model building attempt grid.update(_job); } // finally if (model != null && grid.getScoringInfos() != null && // did model build and scoringInfo creation succeed? _hyperSpaceWalker.stopEarly(model, grid.getScoringInfos())) { Log.info("Convergence detected based on simple moving average of the loss function. Grid building completed."); break; } } // while (it.hasNext(model)) Log.info("For grid: " + grid._key + " built: " + grid.getModelCount() + " models."); } finally { grid.unlock(_job); } } }
public class class_name { private void gridSearch(Grid<MP> grid) { Model model = null; // Prepare nice model key and override default key by appending model counter //String protoModelKey = _hyperSpaceWalker.getParams()._model_id == null // ? grid._key + "_model_" // : _hyperSpaceWalker.getParams()._model_id.toString() + H2O.calcNextUniqueModelId("") + "_"; String protoModelKey = grid._key + "_model_"; try { // Get iterator to traverse hyper space HyperSpaceWalker.HyperSpaceIterator<MP> it = _hyperSpaceWalker.iterator(); // Number of traversed model parameters int counter = grid.getModelCount(); while (it.hasNext(model)) { if (_job.stop_requested()) throw new Job.JobCancelledException(); // Handle end-user cancel request double max_runtime_secs = it.max_runtime_secs(); double time_remaining_secs = Double.MAX_VALUE; if (max_runtime_secs > 0) { time_remaining_secs = it.time_remaining_secs(); // depends on control dependency: [if], data = [none] if (time_remaining_secs < 0) { Log.info("Grid max_runtime_secs of " + max_runtime_secs + " secs has expired; stopping early."); // depends on control dependency: [if], data = [none] throw new Job.JobCancelledException(); } } MP params; try { // Get parameters for next model params = it.nextModelParameters(model); // depends on control dependency: [try], data = [none] // Sequential model building, should never propagate // exception up, just mark combination of model parameters as wrong // Do we need to limit the model build time? if (max_runtime_secs > 0) { Log.info("Grid time is limited to: " + max_runtime_secs + " for grid: " + grid._key + ". Remaining time is: " + time_remaining_secs); // depends on control dependency: [if], data = [none] if (params._max_runtime_secs == 0) { // unlimited params._max_runtime_secs = time_remaining_secs; // depends on control dependency: [if], data = [none] Log.info("Due to the grid time limit, changing model max runtime to: " + params._max_runtime_secs + " secs."); // depends on control dependency: [if], data = [none] } else { double was = params._max_runtime_secs; params._max_runtime_secs = Math.min(params._max_runtime_secs, time_remaining_secs); // depends on control dependency: [if], data = [(params._max_runtime_secs] Log.info("Due to the grid time limit, changing model max runtime from: " + was + " secs to: " + params._max_runtime_secs + " secs."); // depends on control dependency: [if], data = [none] } } try { ScoringInfo scoringInfo = new ScoringInfo(); scoringInfo.time_stamp_ms = System.currentTimeMillis(); // depends on control dependency: [try], data = [none] //// build the model! model = buildModel(params, grid, ++counter, protoModelKey); // depends on control dependency: [try], data = [none] if (model != null) { model.fillScoringInfo(scoringInfo); // depends on control dependency: [if], data = [none] grid.setScoringInfos(ScoringInfo.prependScoringInfo(scoringInfo, grid.getScoringInfos())); // depends on control dependency: [if], data = [none] ScoringInfo.sort(grid.getScoringInfos(), _hyperSpaceWalker.search_criteria().stopping_metric()); // Currently AUTO for Cartesian and user-specified for RandomDiscrete // depends on control dependency: [if], data = [none] } } catch (RuntimeException e) { // Catch everything if (!Job.isCancelledException(e)) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); // depends on control dependency: [if], data = [none] Log.warn("Grid search: model builder for parameters " + params + " failed! Exception: ", e, sw.toString()); // depends on control dependency: [if], data = [none] } grid.appendFailedModelParameters(params, e); } // depends on control dependency: [catch], data = [none] } catch (IllegalArgumentException e) { Log.warn("Grid search: construction of model parameters failed! Exception: ", e); // Model parameters cannot be constructed for some reason it.modelFailed(model); Object[] rawParams = it.getCurrentRawParameters(); grid.appendFailedModelParameters(rawParams, e); } finally { // depends on control dependency: [catch], data = [none] // Update progress by 1 increment _job.update(1); // Always update grid in DKV after model building attempt grid.update(_job); } // finally if (model != null && grid.getScoringInfos() != null && // did model build and scoringInfo creation succeed? _hyperSpaceWalker.stopEarly(model, grid.getScoringInfos())) { Log.info("Convergence detected based on simple moving average of the loss function. Grid building completed."); // depends on control dependency: [if], data = [none] break; } } // while (it.hasNext(model)) Log.info("For grid: " + grid._key + " built: " + grid.getModelCount() + " models."); // depends on control dependency: [try], data = [none] } finally { grid.unlock(_job); } } }
public class class_name { public static String toTimeString(int hour, int minute, int second) { String hourStr; String minuteStr; String secondStr; if (hour < 10) { hourStr = "0" + hour; } else { hourStr = "" + hour; } if (minute < 10) { minuteStr = "0" + minute; } else { minuteStr = "" + minute; } if (second < 10) { secondStr = "0" + second; } else { secondStr = "" + second; } if (second == 0) return hourStr + ":" + minuteStr; else return hourStr + ":" + minuteStr + ":" + secondStr; } }
public class class_name { public static String toTimeString(int hour, int minute, int second) { String hourStr; String minuteStr; String secondStr; if (hour < 10) { hourStr = "0" + hour; // depends on control dependency: [if], data = [none] } else { hourStr = "" + hour; // depends on control dependency: [if], data = [none] } if (minute < 10) { minuteStr = "0" + minute; // depends on control dependency: [if], data = [none] } else { minuteStr = "" + minute; // depends on control dependency: [if], data = [none] } if (second < 10) { secondStr = "0" + second; // depends on control dependency: [if], data = [none] } else { secondStr = "" + second; // depends on control dependency: [if], data = [none] } if (second == 0) return hourStr + ":" + minuteStr; else return hourStr + ":" + minuteStr + ":" + secondStr; } }
public class class_name { public static synchronized PingManager getInstanceFor(XMPPConnection connection) { PingManager pingManager = INSTANCES.get(connection); if (pingManager == null) { pingManager = new PingManager(connection); INSTANCES.put(connection, pingManager); } return pingManager; } }
public class class_name { public static synchronized PingManager getInstanceFor(XMPPConnection connection) { PingManager pingManager = INSTANCES.get(connection); if (pingManager == null) { pingManager = new PingManager(connection); // depends on control dependency: [if], data = [none] INSTANCES.put(connection, pingManager); // depends on control dependency: [if], data = [none] } return pingManager; } }
public class class_name { public static Web3j generateClient(String clientAddress, Long timeoutSeconds) { if (isEmpty(clientAddress)) { throw new IllegalArgumentException("You have to define client address, use constructor or environment variable 'web3j.clientAddress'"); } Web3jService web3jService; if (clientAddress.startsWith("http")) { web3jService = new HttpService(clientAddress, createOkHttpClient(timeoutSeconds), false); } else if (clientAddress.startsWith("wss")) { try { web3jService = new WebSocketService(clientAddress, true); ((WebSocketService) web3jService).connect(); } catch (Exception ex) { throw new RuntimeException(ex); } } else if (System.getProperty("os.name").toLowerCase().startsWith("win")) { web3jService = new WindowsIpcService(clientAddress); } else { web3jService = new UnixIpcService(clientAddress); } return Web3j.build(web3jService); } }
public class class_name { public static Web3j generateClient(String clientAddress, Long timeoutSeconds) { if (isEmpty(clientAddress)) { throw new IllegalArgumentException("You have to define client address, use constructor or environment variable 'web3j.clientAddress'"); } Web3jService web3jService; if (clientAddress.startsWith("http")) { web3jService = new HttpService(clientAddress, createOkHttpClient(timeoutSeconds), false); } else if (clientAddress.startsWith("wss")) { try { web3jService = new WebSocketService(clientAddress, true); // depends on control dependency: [try], data = [none] ((WebSocketService) web3jService).connect(); // depends on control dependency: [try], data = [none] } catch (Exception ex) { throw new RuntimeException(ex); } // depends on control dependency: [catch], data = [none] } else if (System.getProperty("os.name").toLowerCase().startsWith("win")) { web3jService = new WindowsIpcService(clientAddress); } else { web3jService = new UnixIpcService(clientAddress); } return Web3j.build(web3jService); } }
public class class_name { @SuppressWarnings( "unchecked" ) private <T> Class<T> loadClassIfVisible( String className, ClassLoader classLoader ) { try { Class<T> klass = (Class<T>) classLoader.loadClass( className ); return klass; } catch ( ClassNotFoundException e ) { return null; } } }
public class class_name { @SuppressWarnings( "unchecked" ) private <T> Class<T> loadClassIfVisible( String className, ClassLoader classLoader ) { try { Class<T> klass = (Class<T>) classLoader.loadClass( className ); // depends on control dependency: [try], data = [none] return klass; // depends on control dependency: [try], data = [none] } catch ( ClassNotFoundException e ) { return null; } // depends on control dependency: [catch], data = [none] } }
public class class_name { public Boolean getEffectiveInternalSSL() { if (m_internalSSL != null) { return m_internalSSL; } else if (m_defaultConfig != null) { return m_defaultConfig.getEffectiveCallSSL(); } else { return Boolean.FALSE; } } }
public class class_name { public Boolean getEffectiveInternalSSL() { if (m_internalSSL != null) { return m_internalSSL; // depends on control dependency: [if], data = [none] } else if (m_defaultConfig != null) { return m_defaultConfig.getEffectiveCallSSL(); // depends on control dependency: [if], data = [none] } else { return Boolean.FALSE; // depends on control dependency: [if], data = [none] } } }
public class class_name { public void updateVirtualLinkDefinition(VirtualLinkDefinition newVirtualLinkDefinition) throws SIIncorrectCallException, SIResourceException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "updateVirtualLinkDefinition", new Object[] {newVirtualLinkDefinition}); // Get hold of the associated LinkHandler LinkHandler lh = (LinkHandler)_targetDestinationHandler; // We'll do this under a tranaction. This work is not coordinated with the Admin component. // // Create a local UOW LocalTransaction transaction = txManager.createLocalTransaction(true); try { lh.updateLinkDefinition(newVirtualLinkDefinition, transaction); // If the update was successful then commit the unit of work transaction.commit(); } catch (SIResourceException e) { // No FFDC code needed if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "updateVirtualLinkDefinition", e); try { transaction.rollback(); } catch (Throwable et) { // FFDC FFDCFilter.processException( e, "com.ibm.ws.sib.processor.impl.BusHandler.updateVirtualLinkDefinition", "1:359:1.54", this); SibTr.exception(tc, et); } throw e; } catch (RuntimeException e) { // FFDC FFDCFilter.processException( e, "com.ibm.ws.sib.processor.impl.BusHandler.updateVirtualLinkDefinition", "1:373:1.54", this); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exception(tc, e); SibTr.exit(tc, "updateVirtualLinkDefinition", e); } try { transaction.rollback(); } catch (Throwable et) { // FFDC FFDCFilter.processException( e, "com.ibm.ws.sib.processor.impl.BusHandler.updateVirtualLinkDefinition", "1:392:1.54", this); SibTr.exception(tc, et); } throw e; } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "updateVirtualLinkDefinition"); } }
public class class_name { public void updateVirtualLinkDefinition(VirtualLinkDefinition newVirtualLinkDefinition) throws SIIncorrectCallException, SIResourceException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "updateVirtualLinkDefinition", new Object[] {newVirtualLinkDefinition}); // Get hold of the associated LinkHandler LinkHandler lh = (LinkHandler)_targetDestinationHandler; // We'll do this under a tranaction. This work is not coordinated with the Admin component. // // Create a local UOW LocalTransaction transaction = txManager.createLocalTransaction(true); try { lh.updateLinkDefinition(newVirtualLinkDefinition, transaction); // depends on control dependency: [try], data = [none] // If the update was successful then commit the unit of work transaction.commit(); // depends on control dependency: [try], data = [none] } catch (SIResourceException e) { // No FFDC code needed if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "updateVirtualLinkDefinition", e); try { transaction.rollback(); // depends on control dependency: [try], data = [none] } catch (Throwable et) { // FFDC FFDCFilter.processException( e, "com.ibm.ws.sib.processor.impl.BusHandler.updateVirtualLinkDefinition", "1:359:1.54", this); SibTr.exception(tc, et); } // depends on control dependency: [catch], data = [none] throw e; } // depends on control dependency: [catch], data = [none] catch (RuntimeException e) { // FFDC FFDCFilter.processException( e, "com.ibm.ws.sib.processor.impl.BusHandler.updateVirtualLinkDefinition", "1:373:1.54", this); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exception(tc, e); // depends on control dependency: [if], data = [none] SibTr.exit(tc, "updateVirtualLinkDefinition", e); // depends on control dependency: [if], data = [none] } try { transaction.rollback(); // depends on control dependency: [try], data = [none] } catch (Throwable et) { // FFDC FFDCFilter.processException( e, "com.ibm.ws.sib.processor.impl.BusHandler.updateVirtualLinkDefinition", "1:392:1.54", this); SibTr.exception(tc, et); } // depends on control dependency: [catch], data = [none] throw e; } // depends on control dependency: [catch], data = [none] if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "updateVirtualLinkDefinition"); } }
public class class_name { public static <T extends Object> T getFieldValue(Object context, Class<T> expectedType, Field field) { if (!field.isAccessible()) { StringBuilder msg = new StringBuilder(); msg.append("Forcing accessibility for field "); msg.append(field.getName()); msg.append(" on "); msg.append(context.getClass().getName()); msg.append(". "); Log.w(FieldUtils.class.getName(), msg.toString()); field.setAccessible(true); } Object valueObject = null; try { valueObject = field.get(context); } catch (IllegalArgumentException iae) { StringBuilder msg = new StringBuilder(); msg.append("Activity "); msg.append(context.getClass().getName()); msg.append(" is incompatible with the field "); msg.append(field.getName()); msg.append(". "); Log.e(FieldUtils.class.getName(), msg.toString(), iae); } catch (IllegalAccessException iae) { StringBuilder msg = new StringBuilder(); msg.append("Field "); msg.append(field.getName()); msg.append(" on "); msg.append(context.getClass().getName()); msg.append(" cannot be accessed. "); Log.e(FieldUtils.class.getName(), msg.toString(), iae); } return expectedType.cast(valueObject); } }
public class class_name { public static <T extends Object> T getFieldValue(Object context, Class<T> expectedType, Field field) { if (!field.isAccessible()) { StringBuilder msg = new StringBuilder(); msg.append("Forcing accessibility for field "); // depends on control dependency: [if], data = [none] msg.append(field.getName()); // depends on control dependency: [if], data = [none] msg.append(" on "); // depends on control dependency: [if], data = [none] msg.append(context.getClass().getName()); // depends on control dependency: [if], data = [none] msg.append(". "); // depends on control dependency: [if], data = [none] Log.w(FieldUtils.class.getName(), msg.toString()); // depends on control dependency: [if], data = [none] field.setAccessible(true); // depends on control dependency: [if], data = [none] } Object valueObject = null; try { valueObject = field.get(context); // depends on control dependency: [try], data = [none] } catch (IllegalArgumentException iae) { StringBuilder msg = new StringBuilder(); msg.append("Activity "); msg.append(context.getClass().getName()); msg.append(" is incompatible with the field "); msg.append(field.getName()); msg.append(". "); Log.e(FieldUtils.class.getName(), msg.toString(), iae); } // depends on control dependency: [catch], data = [none] catch (IllegalAccessException iae) { StringBuilder msg = new StringBuilder(); msg.append("Field "); msg.append(field.getName()); msg.append(" on "); msg.append(context.getClass().getName()); msg.append(" cannot be accessed. "); Log.e(FieldUtils.class.getName(), msg.toString(), iae); } // depends on control dependency: [catch], data = [none] return expectedType.cast(valueObject); } }
public class class_name { public JsonElement get(String label) { int i = 0; try{ for (JsonElement e : this) { if(e.isPrimitive() && e.asPrimitive().asString().equals(label)) { return e; } else if((e.isObject() || e.isArray()) && Integer.valueOf(label).equals(i)) { return e; } i++; } } catch(NumberFormatException e) { // fail gracefully return null; } // the element was not found return null; } }
public class class_name { public JsonElement get(String label) { int i = 0; try{ for (JsonElement e : this) { if(e.isPrimitive() && e.asPrimitive().asString().equals(label)) { return e; // depends on control dependency: [if], data = [none] } else if((e.isObject() || e.isArray()) && Integer.valueOf(label).equals(i)) { return e; // depends on control dependency: [if], data = [none] } i++; // depends on control dependency: [for], data = [none] } } catch(NumberFormatException e) { // fail gracefully return null; } // depends on control dependency: [catch], data = [none] // the element was not found return null; } }
public class class_name { public static Set<Class<?>> scanForAnnotatedClasses(final File directory, final String packagePath, final Class<? extends Annotation> annotationClass) throws ClassNotFoundException { final Set<Class<?>> foundClasses = new HashSet<>(); if (!directory.exists()) { return foundClasses; } // define the include filefilter for class files... final FileFilter includeFileFilter = new ClassFileFilter(); final File[] files = directory.listFiles(includeFileFilter); for (final File file : files) { String qualifiedClassname = null; if (file.isDirectory()) { qualifiedClassname = packagePath + "." + file.getName(); foundClasses .addAll(scanForAnnotatedClasses(file, qualifiedClassname, annotationClass)); } else { final String filename = FilenameExtensions.getFilenameWithoutExtension(file); qualifiedClassname = packagePath + '.' + filename; Class<?> foundClass = null; try { foundClass = ClassExtensions.forName(qualifiedClassname); if (annotationClass != null) { if (foundClass.isAnnotationPresent(annotationClass)) { foundClasses.add(foundClass); } } else { foundClasses.add(foundClass); } } catch (final Throwable throwable) { foundClass = Class.forName(qualifiedClassname, false, ClassExtensions.getClassLoader()); if (annotationClass != null) { if (foundClass.isAnnotationPresent(annotationClass)) { foundClasses.add(foundClass); } } else { foundClasses.add(foundClass); } } } } return foundClasses; } }
public class class_name { public static Set<Class<?>> scanForAnnotatedClasses(final File directory, final String packagePath, final Class<? extends Annotation> annotationClass) throws ClassNotFoundException { final Set<Class<?>> foundClasses = new HashSet<>(); if (!directory.exists()) { return foundClasses; // depends on control dependency: [if], data = [none] } // define the include filefilter for class files... final FileFilter includeFileFilter = new ClassFileFilter(); final File[] files = directory.listFiles(includeFileFilter); for (final File file : files) { String qualifiedClassname = null; if (file.isDirectory()) { qualifiedClassname = packagePath + "." + file.getName(); // depends on control dependency: [if], data = [none] foundClasses .addAll(scanForAnnotatedClasses(file, qualifiedClassname, annotationClass)); // depends on control dependency: [if], data = [none] } else { final String filename = FilenameExtensions.getFilenameWithoutExtension(file); qualifiedClassname = packagePath + '.' + filename; // depends on control dependency: [if], data = [none] Class<?> foundClass = null; // depends on control dependency: [if], data = [none] try { foundClass = ClassExtensions.forName(qualifiedClassname); // depends on control dependency: [try], data = [none] if (annotationClass != null) { if (foundClass.isAnnotationPresent(annotationClass)) { foundClasses.add(foundClass); // depends on control dependency: [if], data = [none] } } else { foundClasses.add(foundClass); // depends on control dependency: [if], data = [none] } } catch (final Throwable throwable) { foundClass = Class.forName(qualifiedClassname, false, ClassExtensions.getClassLoader()); if (annotationClass != null) { if (foundClass.isAnnotationPresent(annotationClass)) { foundClasses.add(foundClass); // depends on control dependency: [if], data = [none] } } else { foundClasses.add(foundClass); // depends on control dependency: [if], data = [none] } } // depends on control dependency: [catch], data = [none] } } return foundClasses; } }
public class class_name { @Override public void internalInitialize(BeanDeployerEnvironment environment) { preInitialize(); BeanLogger.LOG.creatingBean(getType()); if (getScope() != null) { proxyRequired = isNormalScoped(); } else { proxyRequired = false; } BeanLogger.LOG.qualifiersUsed(getQualifiers(), this); BeanLogger.LOG.usingName(getName(), this); BeanLogger.LOG.usingScope(getScope(), this); } }
public class class_name { @Override public void internalInitialize(BeanDeployerEnvironment environment) { preInitialize(); BeanLogger.LOG.creatingBean(getType()); if (getScope() != null) { proxyRequired = isNormalScoped(); // depends on control dependency: [if], data = [none] } else { proxyRequired = false; // depends on control dependency: [if], data = [none] } BeanLogger.LOG.qualifiersUsed(getQualifiers(), this); BeanLogger.LOG.usingName(getName(), this); BeanLogger.LOG.usingScope(getScope(), this); } }
public class class_name { public static BundleRendererContext getBundleRendererContext(HttpServletRequest request, BundleRenderer renderer) { String bundleRendererCtxAttributeName = BUNDLE_RENDERER_CONTEXT_ATTR_PREFIX + renderer.getResourceType(); // If we are handling an error dispatch, we should remove the current // RendererContext to use a new one String jawrErrorDispathAttributeName = JAWR_ERROR_DISPATCH + renderer.getResourceType(); clearRequestWhenDispatch(request, ERROR_EXCEPTION, bundleRendererCtxAttributeName, jawrErrorDispathAttributeName); // If we are handling a forward dispatch, we should remove the current // RendererContext to use a new one String jawrForwardDispathAttributeName = JAWR_FOWARD_DISPATCH + renderer.getResourceType(); clearRequestWhenDispatch(request, FORWARD_REQUEST_URI, bundleRendererCtxAttributeName, jawrForwardDispathAttributeName); BundleRendererContext ctx = (BundleRendererContext) request.getAttribute(bundleRendererCtxAttributeName); if (ctx == null) { ctx = new BundleRendererContext(request, renderer.getBundler().getConfig()); request.setAttribute(bundleRendererCtxAttributeName, ctx); } return ctx; } }
public class class_name { public static BundleRendererContext getBundleRendererContext(HttpServletRequest request, BundleRenderer renderer) { String bundleRendererCtxAttributeName = BUNDLE_RENDERER_CONTEXT_ATTR_PREFIX + renderer.getResourceType(); // If we are handling an error dispatch, we should remove the current // RendererContext to use a new one String jawrErrorDispathAttributeName = JAWR_ERROR_DISPATCH + renderer.getResourceType(); clearRequestWhenDispatch(request, ERROR_EXCEPTION, bundleRendererCtxAttributeName, jawrErrorDispathAttributeName); // If we are handling a forward dispatch, we should remove the current // RendererContext to use a new one String jawrForwardDispathAttributeName = JAWR_FOWARD_DISPATCH + renderer.getResourceType(); clearRequestWhenDispatch(request, FORWARD_REQUEST_URI, bundleRendererCtxAttributeName, jawrForwardDispathAttributeName); BundleRendererContext ctx = (BundleRendererContext) request.getAttribute(bundleRendererCtxAttributeName); if (ctx == null) { ctx = new BundleRendererContext(request, renderer.getBundler().getConfig()); // depends on control dependency: [if], data = [none] request.setAttribute(bundleRendererCtxAttributeName, ctx); // depends on control dependency: [if], data = [none] } return ctx; } }
public class class_name { public List getSelectedBeans() { ArrayList<Object> list = new ArrayList<>(); int[] viewRowIndices = jtable.getSelectedRows(); for (int viewRowIndex : viewRowIndices) { int modelRowIndex = jtable.convertRowIndexToModel(viewRowIndex); list.add(beans.get(modelRowIndex)); if (debugSelected) System.out.println(" bean selected= " + modelRowIndex + " " + beans.get(modelRowIndex)); } return list; } }
public class class_name { public List getSelectedBeans() { ArrayList<Object> list = new ArrayList<>(); int[] viewRowIndices = jtable.getSelectedRows(); for (int viewRowIndex : viewRowIndices) { int modelRowIndex = jtable.convertRowIndexToModel(viewRowIndex); list.add(beans.get(modelRowIndex)); // depends on control dependency: [for], data = [none] if (debugSelected) System.out.println(" bean selected= " + modelRowIndex + " " + beans.get(modelRowIndex)); } return list; } }
public class class_name { private IConsoleColorProvider getColorProvider(String type) { if (fColorProviders == null) { fColorProviders = new HashMap<String, IConfigurationElement>(); IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.EXTENSION_POINT_CONSOLE_COLOR_PROVIDERS); IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); for (int i = 0; i < elements.length; i++) { IConfigurationElement extension = elements[i]; fColorProviders.put(extension.getAttribute("processType"), extension); //$NON-NLS-1$ } } IConfigurationElement extension = fColorProviders.get(type); if (extension != null) { try { Object colorProvider = extension.createExecutableExtension("class"); //$NON-NLS-1$ if (colorProvider instanceof IConsoleColorProvider) { return (IConsoleColorProvider) colorProvider; } VdmDebugPlugin.logError(MessageFormat.format("Extension {0} must specify an instanceof IConsoleColorProvider for class attribute.", //$NON-NLS-1$ new Object[] { extension.getDeclaringExtension().getUniqueIdentifier() })); } catch (CoreException e) { VdmDebugPlugin.log(e); } } // no color provider found of specified type, return default color // provider. if (fDefaultColorProvider == null) { fDefaultColorProvider = new ConsoleColorProvider(); } return fDefaultColorProvider; } }
public class class_name { private IConsoleColorProvider getColorProvider(String type) { if (fColorProviders == null) { fColorProviders = new HashMap<String, IConfigurationElement>(); // depends on control dependency: [if], data = [none] IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.EXTENSION_POINT_CONSOLE_COLOR_PROVIDERS); IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); for (int i = 0; i < elements.length; i++) { IConfigurationElement extension = elements[i]; fColorProviders.put(extension.getAttribute("processType"), extension); //$NON-NLS-1$ // depends on control dependency: [for], data = [none] } } IConfigurationElement extension = fColorProviders.get(type); if (extension != null) { try { Object colorProvider = extension.createExecutableExtension("class"); //$NON-NLS-1$ if (colorProvider instanceof IConsoleColorProvider) { return (IConsoleColorProvider) colorProvider; // depends on control dependency: [if], data = [none] } VdmDebugPlugin.logError(MessageFormat.format("Extension {0} must specify an instanceof IConsoleColorProvider for class attribute.", //$NON-NLS-1$ new Object[] { extension.getDeclaringExtension().getUniqueIdentifier() })); // depends on control dependency: [try], data = [none] } catch (CoreException e) { VdmDebugPlugin.log(e); } // depends on control dependency: [catch], data = [none] } // no color provider found of specified type, return default color // provider. if (fDefaultColorProvider == null) { fDefaultColorProvider = new ConsoleColorProvider(); // depends on control dependency: [if], data = [none] } return fDefaultColorProvider; } }
public class class_name { public ListResourceRecordSetsResult withResourceRecordSets(ResourceRecordSet... resourceRecordSets) { if (this.resourceRecordSets == null) { setResourceRecordSets(new com.amazonaws.internal.SdkInternalList<ResourceRecordSet>(resourceRecordSets.length)); } for (ResourceRecordSet ele : resourceRecordSets) { this.resourceRecordSets.add(ele); } return this; } }
public class class_name { public ListResourceRecordSetsResult withResourceRecordSets(ResourceRecordSet... resourceRecordSets) { if (this.resourceRecordSets == null) { setResourceRecordSets(new com.amazonaws.internal.SdkInternalList<ResourceRecordSet>(resourceRecordSets.length)); // depends on control dependency: [if], data = [none] } for (ResourceRecordSet ele : resourceRecordSets) { this.resourceRecordSets.add(ele); // depends on control dependency: [for], data = [ele] } return this; } }
public class class_name { public void addInputDeletions(VersionEdit edit) { for (FileMetaData input : levelInputs) { edit.deleteFile(level, input.getNumber()); } for (FileMetaData input : levelUpInputs) { edit.deleteFile(level + 1, input.getNumber()); } } }
public class class_name { public void addInputDeletions(VersionEdit edit) { for (FileMetaData input : levelInputs) { edit.deleteFile(level, input.getNumber()); // depends on control dependency: [for], data = [input] } for (FileMetaData input : levelUpInputs) { edit.deleteFile(level + 1, input.getNumber()); // depends on control dependency: [for], data = [input] } } }
public class class_name { private static void doFieldMapping(BeanMappingParam param, BeanMappingField beanField, BatchObjectHolder holder) { // 定义valueContext ValueProcessContext valueContext = new ValueProcessContext(param, param.getConfig(), beanField, holder, param.getCustomValueContext()); // 设置getExecutor GetExecutor getExecutor = beanField.getGetExecutor();// 优先从beanField里取 if (getExecutor == null && StringUtils.isNotEmpty(beanField.getSrcField().getName())) {// 如果不为空,可能存在script Class locatorClass = beanField.getSrcField().getLocatorClass();// 从locatorClass中获取 if (locatorClass == null) { locatorClass = param.getSrcRef().getClass(); beanField.getSrcField().setLocatorClass(locatorClass); } getExecutor = Uberspector.getInstance().getGetExecutor(locatorClass, beanField.getSrcField().getName()); beanField.setGetExecutor(getExecutor); } // 设置setExecutor SetExecutor setExecutor = beanField.getSetExecutor();// 优先从beanField里取 if (setExecutor == null && StringUtils.isNotEmpty(beanField.getTargetField().getName())) { Class locatorClass = beanField.getTargetField().getLocatorClass();// 从locatorClass中获取 if (locatorClass == null) { locatorClass = param.getTargetRef().getClass(); beanField.getTargetField().setLocatorClass(locatorClass); } setExecutor = Uberspector.getInstance().getSetExecutor(locatorClass, beanField.getTargetField().getName(), beanField.getTargetField().getClazz()); beanField.setSetExecutor(setExecutor); } // 获取get结果 ValueProcessInvocation invocation = new ValueProcessInvocation(getExecutor, setExecutor, valueContext, param.getProcesses()); Object getResult = invocation.getInitialValue(); // 设置下srcClass Class getResultClass = (getResult != null) ? getResult.getClass() : null; if (getExecutor != null && beanField.getSrcField().getClazz() == null) { beanField.getSrcField().setClazz( Uberspector.getInstance().getGetClass(getExecutor, param.getSrcRef().getClass(), getResultClass)); } // 设置下targetClass if (setExecutor != null && beanField.getTargetField().getClazz() == null) { beanField.getTargetField().setClazz( Uberspector.getInstance().getSetClass(setExecutor, param.getTargetRef().getClass(), getResultClass)); } // 开始ValueProcess流程 invocation.proceed(getResult); } }
public class class_name { private static void doFieldMapping(BeanMappingParam param, BeanMappingField beanField, BatchObjectHolder holder) { // 定义valueContext ValueProcessContext valueContext = new ValueProcessContext(param, param.getConfig(), beanField, holder, param.getCustomValueContext()); // 设置getExecutor GetExecutor getExecutor = beanField.getGetExecutor();// 优先从beanField里取 if (getExecutor == null && StringUtils.isNotEmpty(beanField.getSrcField().getName())) {// 如果不为空,可能存在script Class locatorClass = beanField.getSrcField().getLocatorClass();// 从locatorClass中获取 if (locatorClass == null) { locatorClass = param.getSrcRef().getClass(); // depends on control dependency: [if], data = [none] beanField.getSrcField().setLocatorClass(locatorClass); // depends on control dependency: [if], data = [(locatorClass] } getExecutor = Uberspector.getInstance().getGetExecutor(locatorClass, beanField.getSrcField().getName()); // depends on control dependency: [if], data = [none] beanField.setGetExecutor(getExecutor); // depends on control dependency: [if], data = [(getExecutor] } // 设置setExecutor SetExecutor setExecutor = beanField.getSetExecutor();// 优先从beanField里取 if (setExecutor == null && StringUtils.isNotEmpty(beanField.getTargetField().getName())) { Class locatorClass = beanField.getTargetField().getLocatorClass();// 从locatorClass中获取 if (locatorClass == null) { locatorClass = param.getTargetRef().getClass(); // depends on control dependency: [if], data = [none] beanField.getTargetField().setLocatorClass(locatorClass); // depends on control dependency: [if], data = [(locatorClass] } setExecutor = Uberspector.getInstance().getSetExecutor(locatorClass, beanField.getTargetField().getName(), beanField.getTargetField().getClazz()); // depends on control dependency: [if], data = [none] beanField.setSetExecutor(setExecutor); // depends on control dependency: [if], data = [(setExecutor] } // 获取get结果 ValueProcessInvocation invocation = new ValueProcessInvocation(getExecutor, setExecutor, valueContext, param.getProcesses()); Object getResult = invocation.getInitialValue(); // 设置下srcClass Class getResultClass = (getResult != null) ? getResult.getClass() : null; if (getExecutor != null && beanField.getSrcField().getClazz() == null) { beanField.getSrcField().setClazz( Uberspector.getInstance().getGetClass(getExecutor, param.getSrcRef().getClass(), getResultClass)); // depends on control dependency: [if], data = [none] } // 设置下targetClass if (setExecutor != null && beanField.getTargetField().getClazz() == null) { beanField.getTargetField().setClazz( Uberspector.getInstance().getSetClass(setExecutor, param.getTargetRef().getClass(), getResultClass)); // depends on control dependency: [if], data = [none] } // 开始ValueProcess流程 invocation.proceed(getResult); } }
public class class_name { public static Type resolveRawGeneric(final TypeVariable variable, final LinkedHashMap<String, Type> generics) { final Type res; if (variable.getBounds().length > 1) { // case: T extends A & B --> ? extends A & B final List<Type> types = new ArrayList<Type>(); for (Type bound : variable.getBounds()) { // replace possible named generics with actual type (for cases like K extends T) final Type actual = GenericsUtils.resolveTypeVariables(bound, generics); if (actual instanceof WildcardType && ((WildcardType) actual).getUpperBounds().length > 0) { // case: T extends A & B, K extends T & C --> K must be aggregated as ? extends A & B & C // this case is impossible in java, but allowed in groovy types.addAll(Arrays.asList(GenericsUtils .resolveTypeVariables(((WildcardType) actual).getUpperBounds(), generics))); } else { types.add(actual); } } // case: T extends Object & Something (may appear because of transitive generics resolution) // only one object could appear (because wildcard could only be // ? extends type (or generic) & exact interface (& exact interface)) // (repackaged from type declaration) types.remove(Object.class); if (types.size() > 1) { // repackaging as impossible wildcard <? extends A & B> to store all known information res = WildcardTypeImpl.upper(types.toArray(new Type[0])); } else { // if one type remain - use it directly; if no types remain - use Object res = types.isEmpty() ? Object.class : types.get(0); } } else { // case: simple generic declaration <T> (implicitly extends Object) res = GenericsUtils.resolveTypeVariables(variable.getBounds()[0], generics); } return res; } }
public class class_name { public static Type resolveRawGeneric(final TypeVariable variable, final LinkedHashMap<String, Type> generics) { final Type res; if (variable.getBounds().length > 1) { // case: T extends A & B --> ? extends A & B final List<Type> types = new ArrayList<Type>(); for (Type bound : variable.getBounds()) { // replace possible named generics with actual type (for cases like K extends T) final Type actual = GenericsUtils.resolveTypeVariables(bound, generics); if (actual instanceof WildcardType && ((WildcardType) actual).getUpperBounds().length > 0) { // case: T extends A & B, K extends T & C --> K must be aggregated as ? extends A & B & C // this case is impossible in java, but allowed in groovy types.addAll(Arrays.asList(GenericsUtils .resolveTypeVariables(((WildcardType) actual).getUpperBounds(), generics))); // depends on control dependency: [if], data = [none] } else { types.add(actual); // depends on control dependency: [if], data = [none] } } // case: T extends Object & Something (may appear because of transitive generics resolution) // only one object could appear (because wildcard could only be // ? extends type (or generic) & exact interface (& exact interface)) // (repackaged from type declaration) types.remove(Object.class); // depends on control dependency: [if], data = [none] if (types.size() > 1) { // repackaging as impossible wildcard <? extends A & B> to store all known information res = WildcardTypeImpl.upper(types.toArray(new Type[0])); // depends on control dependency: [if], data = [none] } else { // if one type remain - use it directly; if no types remain - use Object res = types.isEmpty() ? Object.class : types.get(0); // depends on control dependency: [if], data = [none] } } else { // case: simple generic declaration <T> (implicitly extends Object) res = GenericsUtils.resolveTypeVariables(variable.getBounds()[0], generics); // depends on control dependency: [if], data = [none] } return res; } }