code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static IntSet difference (IntSet set1, IntSet set2)
{
return and(set1, notView(set2));
} | java |
protected static void checkNotNull (Object[] array)
{
checkNotNull((Object)array);
for (Object o : array) {
checkNotNull(o);
}
} | java |
public void setSentinel (int sentinel)
{
if (_sentinel == sentinel) {
return;
}
if (contains(sentinel)) {
throw new IllegalArgumentException("Set contains sentinel value " + sentinel);
}
// replace every instance of the old sentinel with the new
... | java |
public Interator interator ()
{
return new AbstractInterator() {
public boolean hasNext () {
checkConcurrentModification();
return _pos < _size;
}
public int nextInt () {
checkConcurrentModification();
if (_p... | java |
protected void rehash (int ncount)
{
int[] obuckets = _buckets;
createBuckets(ncount);
for (int idx = 0, pos = 0; pos < _size; idx++) {
int value = obuckets[idx];
if (value != _sentinel) {
readd(value);
pos++;
}
}
... | java |
protected void readd (int value)
{
int mask = _buckets.length - 1;
int start = hash(value) & mask, idx = start;
do {
if (_buckets[idx] == _sentinel) {
_buckets[idx] = value;
return;
}
} while ((idx = idx + 1 & mask) != start);
... | java |
private void writeObject (ObjectOutputStream out)
throws IOException
{
out.defaultWriteObject();
for (int idx = 0, pos = 0; pos < _size; idx++) {
int value = _buckets[idx];
if (value != _sentinel) {
out.writeInt(value);
pos++;
... | java |
private void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
in.defaultReadObject();
createBuckets(getBucketCount(_size));
for (int ii = 0; ii < _size; ii++) {
readd(in.readInt());
}
} | java |
protected static int getBucketCount (int capacity, float loadFactor)
{
int size = (int)(capacity / loadFactor);
int highest = Integer.highestOneBit(size);
return Math.max((size == highest) ? highest : (highest << 1), MIN_BUCKET_COUNT);
} | java |
private void setGridAxisColors(ro.nextreports.jofc2.model.Chart flashChart, XAxis xAxis, YAxis yAxis) {
boolean isHorizontal = chart.getType().isHorizontal();
Color xGridColor = chart.getXGridColor();
Color yGridColor = chart.getYGridColor();
if (xGridColor != null) {
getXAxi... | java |
private void setTicks(XAxis xAxis, YAxis yAxis, boolean showXLabel, boolean showYLabel) {
boolean isHorizontal = chart.getType().isHorizontal();
if ((!showXLabel && !isHorizontal) || (!showYLabel && isHorizontal)) {
xAxis.setTickHeight(0);
}
if ((!showYLabel && !isHorizontal... | java |
public void hijack ()
{
_mls = _comp.getMouseListeners();
for (int ii=0; ii < _mls.length; ii++) {
_comp.removeMouseListener(_mls[ii]);
}
_mmls = _comp.getMouseMotionListeners();
for (int ii=0; ii < _mmls.length; ii++) {
_comp.removeMouseMotionListene... | java |
public static Cookie getCookie (HttpServletRequest req, String name)
{
Cookie[] cookies = req.getCookies();
if (cookies != null) {
for (int ii=0, nn=cookies.length; ii < nn; ii++) {
if (cookies[ii].getName().equals(name)) {
return cookies[ii];
... | java |
public static String getCookieValue (HttpServletRequest req, String name)
{
Cookie c = getCookie(req, name);
return (c == null) ? null : c.getValue();
} | java |
public static void clearCookie (HttpServletResponse rsp, String name)
{
Cookie c = new Cookie(name, "x");
c.setPath("/");
c.setMaxAge(0);
rsp.addCookie(c);
} | java |
public final String translate (InvocationContext ctx, String msg)
{
return _msgmgr.getMessage(ctx.getRequest(), msg);
} | java |
private void addMetaData() {
document.addTitle(getDocumentTitle());
document.addAuthor(ReleaseInfoAdapter.getCompany());
document.addCreator("NextReports " + ReleaseInfoAdapter.getVersionNumber());
document.addSubject("Created by NextReports Designer" + ReleaseInfoAdapter.getVersionNumber());
document.addCrea... | java |
public void reinit (int operations, long period)
{
_period = period;
if (operations != _ops.length) {
long[] ops = new long[operations];
if (operations > _ops.length) {
// copy to a larger buffer, leaving zeroes at the beginning
int lastOp = _... | java |
public static String stripBlankLines(String text) {
if (text == null) {
return null;
}
try {
StringBuffer output = new StringBuffer();
BufferedReader in = new BufferedReader(new StringReader(text));
boolean doneOneLine = false;
while (... | java |
public static String stripMultiLineComments(String text) {
if (text == null) {
return null;
}
try {
StringBuffer output = new StringBuffer();
// Comment rules:
/*/ This is still a comment
/* /* */ // Comments do not nes... | java |
public static String stripSingleLineComments(String text) {
if (text == null) {
return null;
}
try {
StringBuffer output = new StringBuffer();
// First we strip multi line comments. I think this is important:
BufferedReader in = new BufferedReade... | java |
public static String trimLines(String text) {
if (text == null) {
return null;
}
try {
StringBuffer output = new StringBuffer();
// First we strip multi line comments. I think this is important:
BufferedReader in = new BufferedReader(new StringRe... | java |
public static String deleteExcededSpaces(String text) {
int size = text.length();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < size; i++) {
char ch = text.charAt(i);
if (ch == ' ') {
if (i > 0) {
char ch2 = text.charAt(i-1);
... | java |
public User loadUser (HttpServletRequest req)
throws PersistenceException
{
String authcook = CookieUtil.getCookieValue(req, _userAuthCookie);
if (USERMGR_DEBUG) {
log.info("Loading user by cookie", _userAuthCookie, authcook);
}
return loadUser(authcook);
} | java |
public User loadUser (String authcode)
throws PersistenceException
{
User user = (authcode == null) ? null : _repository.loadUserBySession(authcode);
if (USERMGR_DEBUG) {
log.info("Loaded user by authcode", "code", authcode, "user", user);
}
return user;
} | java |
public User login (String username, Password password, boolean persist,
HttpServletRequest req, HttpServletResponse rsp, Authenticator auth)
throws PersistenceException, AuthenticationFailedException
{
// load up the requested user
User user = _repository.loadUser(user... | java |
public void effectLogin (
User user, int expires, HttpServletRequest req, HttpServletResponse rsp)
throws PersistenceException
{
String authcode = _repository.registerSession(user, Math.max(expires, 1));
Cookie acookie = new Cookie(_userAuthCookie, authcode);
// strip the hos... | java |
public boolean exists (HttpServletRequest req, String path)
{
return (getMessage(req, path, false) != null);
} | java |
public String getMessage (HttpServletRequest req, String path)
{
return getMessage(req, path, true);
} | java |
protected ResourceBundle[] resolveBundles (HttpServletRequest req)
{
// first look to see if we've cached the bundles for this request in the request object
ResourceBundle[] bundles = null;
if (req != null) {
bundles = (ResourceBundle[])req.getAttribute(getBundleCacheName());
... | java |
protected ResourceBundle resolveBundle (HttpServletRequest req, String bundlePath,
ClassLoader loader, boolean silent)
{
ResourceBundle bundle = null;
if (req != null) {
Enumeration<?> locales = req.getLocales();
while (locales.has... | java |
public static boolean unpackJar (JarFile jar, File target)
{
boolean failure = false;
Enumeration<?> entries = jar.entries();
while (!failure && entries.hasMoreElements()) {
JarEntry entry = (JarEntry)entries.nextElement();
File efile = new File(target, entry.getName(... | java |
public void setControlledPanel (final JComponent panel)
{
panel.addHierarchyListener(new HierarchyListener() {
public void hierarchyChanged (HierarchyEvent e) {
boolean nowShowing = panel.isDisplayable();
//System.err.println("Controller." + Controller.this +
... | java |
public boolean handleAction (ActionEvent action)
{
Object arg = null;
if (action instanceof CommandEvent) {
arg = ((CommandEvent)action).getArgument();
}
return handleAction(action.getSource(), action.getActionCommand(), arg);
} | java |
protected static void obtainTermSize ()
{
if (_tdimens == null) {
_tdimens = TermUtil.getTerminalSize();
// if we were unable to obtain our dimensions, use defaults
if (_tdimens == null) {
_tdimens = new Dimension(132, 24);
}
}
} | java |
private void put(PrintStream p, String s) {
if (s == null) {
// nl();
put(p, " ");
return;
}
if (wasPreviousField) {
p.print(separator);
}
if (trim) {
s = s.trim();
}
if (s.indexOf(quote) >= 0) {
... | java |
public static void activate ()
{
// capture low-level keyboard events via the keyboard focus manager
if (_dispatcher == null) {
_dispatcher = new KeyEventDispatcher() {
public boolean dispatchKeyEvent (KeyEvent e) {
return DebugChords.dispatchKeyEvent(... | java |
public static void registerHook (int modifierMask, int keyCode, Hook hook)
{
// store the hooks mapped by key code
ArrayList<Tuple<Integer,Hook>> list = _bindings.get(keyCode);
if (list == null) {
list = new ArrayList<Tuple<Integer,Hook>>();
_bindings.put(keyCode, lis... | java |
public V next ()
throws SQLException
{
// if we closed everything up after the last call to next(),
// table will be null here and we should bail immediately
if (_table == null) {
return null;
}
if (_result == null) {
if (_qbeObject != null) {... | java |
public V get ()
throws SQLException
{
V result = next();
if (result != null) {
int spurious = 0;
while (next() != null) {
spurious++;
}
if (spurious > 0) {
log.warning("Cursor.get() quietly tossed " + spurious + ... | java |
public void close ()
throws SQLException
{
if (_result != null) {
_result.close();
_result = null;
}
if (_stmt != null) {
_stmt.close();
_stmt = null;
}
} | java |
public void setReport(Report report) {
this.report = report;
if (this.report.getQuery() != null) {
this.report.getQuery().setDialect(dialect);
}
} | java |
public void setAlerts(List<Alert> alerts) {
if (format == null) {
throw new IllegalStateException(
"You have to use setFormat with a valid output format before using setAlert!");
}
if (!ALARM_FORMAT.equals(format) && !INDICATOR_FORMAT.equals(format) && !DISPLAY_FORMAT.equals(format)) {
throw new Illega... | java |
public QueryResult executeQuery() throws ReportRunnerException, InterruptedException {
if (connection == null) {
throw new ReportRunnerException("Connection is null!");
}
if (report == null) {
throw new ReportRunnerException("Report is null!");
}
String sql = getSql();
// retrieves the report parame... | java |
public boolean run(OutputStream stream) throws ReportRunnerException, NoDataFoundException {
if ((stream == null) && !TABLE_FORMAT.equals(format) && !ALARM_FORMAT.equals(format)
&& !INDICATOR_FORMAT.equals(format) && !DISPLAY_FORMAT.equals(format)) {
throw new ReportRunnerException("OutputStream cannot be nul... | java |
public void removeExporterEventListener(ExporterEventListener listener) {
listenerList.remove(listener);
if (exporter != null) {
exporter.removeExporterEventListener(listener);
}
} | java |
public AlarmData getAlarmData() {
if (ALARM_FORMAT.equals(format)) {
AlarmExporter alarmExporter = (AlarmExporter) exporter;
return alarmExporter.getData();
} else {
return new AlarmData();
}
} | java |
public IndicatorData getIndicatorData() {
if (INDICATOR_FORMAT.equals(format)) {
IndicatorExporter ie = (IndicatorExporter) exporter;
return ie.getData();
} else {
return new IndicatorData();
}
} | java |
public DisplayData getDisplayData() {
if (DISPLAY_FORMAT.equals(format)) {
DisplayExporter de = (DisplayExporter) exporter;
return de.getData();
} else {
return new DisplayData();
}
} | java |
protected void flush ()
{
if (!_canFlush) {
return;
}
// If we've exceeded our size, remove things until we're back
// under the required size.
if (_size > _maxSize) {
// This works because the entrySet iterator of a LinkedHashMap
// retur... | java |
protected void entryRemoved (V entry)
{
if (entry != null) {
_size -= _sizer.computeSize(entry);
if (_remobs != null) {
_remobs.removedFromMap(this, entry);
}
}
} | java |
public static <T> ExpiringReference<T> create (T value, long expireMillis)
{
return new ExpiringReference<T>(value, expireMillis);
} | java |
public static <T> T get (ExpiringReference<T> value)
{
return (value == null) ? null : value.getValue();
} | java |
public T getValue ()
{
// if the value is still around and it's expired, clear it
if (_value != null && System.currentTimeMillis() >= _expires) {
_value = null;
}
// then return the value (which may be cleared to null by now)
return _value;
} | java |
public static JMenuItem addMenuItem (
ActionListener l, JMenu menu, String name)
{
return addMenuItem(l, menu, name, null, null);
} | java |
protected static JMenuItem createItem (String name, Integer mnem, KeyStroke accel)
{
JMenuItem item = new JMenuItem(name);
if (mnem != null) {
item.setMnemonic(mnem.intValue());
}
if (accel != null) {
item.setAccelerator(accel);
}
return item;
... | java |
public void setText (String text)
{
if (_label.setText(text)) {
_dirty = true;
// clear out our constrained size where appropriate
if (_constrain == HORIZONTAL || _constrain == VERTICAL) {
_constrainedSize = 0;
_label.clearTargetDimens();
... | java |
protected void layoutLabel ()
{
Graphics2D gfx = (Graphics2D)getGraphics();
if (gfx != null) {
// re-layout the label
_label.layout(gfx);
gfx.dispose();
// note that we're no longer dirty
_dirty = false;
}
} | java |
public static Dialect determineDialect(String databaseName, String databaseMajorVersion)
throws DialectException {
if (databaseName == null) {
throw new DialectException("Dialect must be explicitly set");
}
String dialectName;
// TODO workaround ... | java |
public static Dialect buildDialect(String dialectName) throws DialectException {
try {
return (Dialect) loadDialect(dialectName).newInstance();
} catch (ClassNotFoundException e) {
throw new DialectException("Dialect class not found: " + dialectName);
} catch (Exception e... | java |
public static Runnable asRunnable (Object instance, String methodName)
{
Class<?> clazz = instance.getClass();
Method method = findMethod(clazz, methodName);
if (Modifier.isStatic(method.getModifiers())) {
throw new IllegalArgumentException(
clazz.getName() + "." ... | java |
public static Runnable asRunnable (Class<?> clazz, String methodName)
{
Method method = findMethod(clazz, methodName);
if (!Modifier.isStatic(method.getModifiers())) {
throw new IllegalArgumentException(
clazz.getName() + "." + methodName + "() must be static");
}... | java |
public void setConnection(Connection connection, boolean csv) {
this.connection = connection;
this.csv = csv;
try {
dialect = DialectUtil.getDialect(connection);
} catch (Exception e) {
e.printStackTrace();
}
if (chart != null) {
if (chart.getRepo... | java |
public void setChart(Chart chart) {
this.chart = chart;
if (this.chart.getReport().getQuery() != null) {
this.chart.getReport().getQuery().setDialect(dialect);
}
} | java |
public boolean run(OutputStream stream) throws ReportRunnerException,
NoDataFoundException, InterruptedException {
if ((stream == null) && GRAPHIC_FORMAT.equals(format)) {
throw new ReportRunnerException("OutputStream cannot be null!");
}
if ((stream != null) && TABLE_FORMAT.equa... | java |
public static void configureDefaultHandler (int maxRepeat)
{
Logger logger = LogManager.getLogManager().getLogger("");
Handler[] handlers = logger.getHandlers();
RepeatRecordFilter filter = new RepeatRecordFilter(maxRepeat);
for (int ii = 0; ii < handlers.length; ii++) {
... | java |
public static int levelFromString (String level)
{
if (level.equalsIgnoreCase("debug")) {
return DEBUG;
} else if (level.equalsIgnoreCase("info")) {
return INFO;
} else if (level.equalsIgnoreCase("warning")) {
return WARNING;
} else {
r... | java |
protected static Dimension getSizeViaResize ()
{
BufferedReader bin = null;
try {
Process proc = Runtime.getRuntime().exec("resize");
InputStream in = proc.getInputStream();
bin = new BufferedReader(new InputStreamReader(in));
Pattern regex = Pattern.c... | java |
protected static int safeToInt (String intstr)
{
if (!StringUtil.isBlank(intstr)) {
try {
return Integer.parseInt(intstr);
} catch (NumberFormatException nfe) {
}
}
return -1;
} | java |
protected void append0 (T item, boolean notify)
{
if (_count == _size) {
makeMoreRoom();
}
_items[_end] = item;
_end = (_end + 1) % _size;
_count++;
if (notify) {
notify();
}
} | java |
public synchronized T getNonBlocking ()
{
if (_count == 0) {
return null;
}
// pull the object off, and clear our reference to it
T retval = _items[_start];
_items[_start] = null;
_start = (_start + 1) % _size;
_count--;
return retval;
... | java |
public synchronized T get ()
{
while (_count == 0) {
try { wait(); } catch (InterruptedException e) {}
}
// pull the object off, and clear our reference to it
T retval = _items[_start];
_items[_start] = null;
_start = (_start + 1) % _size;
_count... | java |
private void shrink ()
{
T[] items = newArray(_size / 2);
if (_start > _end) {
// the data wraps around
System.arraycopy(_items, _start, items, 0, _size - _start);
System.arraycopy(_items, 0, items, _size - _start, _end + 1);
} else {
// the ... | java |
@ReplacedBy("com.google.common.collect.Iterators#addAll(Collection, com.google.common.collect.Iterators#forEnumeration(Enumeration))")
public static <T, C extends Collection<T>> C addAll (C col, Enumeration<? extends T> enm)
{
while (enm.hasMoreElements()) {
col.add(enm.nextElement());
... | java |
@ReplacedBy("com.google.common.collect.Iterators#addAll()")
public static <T, C extends Collection<T>> C addAll (C col, Iterator<? extends T> iter)
{
while (iter.hasNext()) {
col.add(iter.next());
}
return col;
} | java |
@ReplacedBy("java.util.Collections#addAll()")
public static <T, E extends T, C extends Collection<T>> C addAll (C col, E[] values)
{
if (values != null) {
for (E value : values) {
col.add(value);
}
}
return col;
} | java |
public static <T, C extends Collection<T>> C addAll (
C col, Iterable<? extends Collection<? extends T>> values)
{
for (Collection<? extends T> val : values) {
col.addAll(val);
}
return col;
} | java |
public static <K, V, M extends Map<K, V>> M putAll (
M map, Iterable<? extends Map<? extends K, ? extends V>> values)
{
for (Map<? extends K, ? extends V> val : values) {
map.putAll(val);
}
return map;
} | java |
public void parametersAreDefined(Report report) throws ParameterNotFoundException {
String[] paramNames;
String sql = report.getSql();
if (sql == null) {
sql = report.getQuery().toString();
}
Query query = new Query(sql);
paramNames = query.getParameterNames()... | java |
public static List<IdName> getRuntimeParameterValues(Connection con, QueryParameter qp, Map<String, QueryParameter> map,
Map<String, Object> vals) throws Exception {
List<IdName> values = new ArrayList<IdName>();
if (qp.isManualSource(... | java |
public static List<IdName> getParameterValues(Connection con, QueryParameter qp, Map<String, QueryParameter> map,
Map<String, Serializable> vals) throws Exception {
Map<String, Object> objVals = new HashMap<String, Object>();
for (String key :... | java |
public static ArrayList<Serializable> getDefaultSourceValues(Connection con, QueryParameter qp) throws Exception {
ArrayList<Serializable> result = new ArrayList<Serializable>();
List<IdName> list = getSelectValues(con, qp.getDefaultSource(), false, QueryParameter.NO_ORDER);
if (QueryPar... | java |
public static Map<String, QueryParameter> getUsedNotHiddenParametersMap(Report report) {
return getUsedParametersMap(report, false, false);
} | java |
public static Map<String, QueryParameter> getUsedHiddenParametersMap(Report report) {
return getUsedParametersMap(report, false, true);
} | java |
public static Map<String, QueryParameter> getUsedParametersMap(Query query, Map<String, QueryParameter> allParameters) {
Set<String> paramNames = new HashSet<String>(Arrays.asList(query.getParameterNames()));
for (QueryParameter p : allParameters.values()) {
paramNames.addAll(p.ge... | java |
public static Map<String, QueryParameter> getUsedParametersMap(String sql, Map<String, QueryParameter> allParameters) {
Query query = new Query(sql);
return getUsedParametersMap(query, allParameters);
} | java |
public static boolean allParametersAreHidden(Map<String, QueryParameter> map) {
for (QueryParameter qp : map.values()) {
if (!qp.isHidden()) {
return false;
}
}
return true;
} | java |
public static boolean allParametersHaveDefaults(Map<String, QueryParameter> map) {
for (QueryParameter qp : map.values()) {
if ((qp.getDefaultValues() == null) || (qp.getDefaultValues().size() == 0)) {
if ((qp.getDefaultSource() == null) || "".equals(qp.getDefaultSource().trim())) {
... | java |
public static void initAllRuntimeParameterValues(QueryParameter param,
List<IdName> values, Map<String, Object> parameterValues) throws QueryException {
if (param.getSelection().equals(QueryParameter.SINGLE_SELECTION)) {
parameterValues.put(param.ge... | java |
public static void initDefaultParameterValues(QueryParameter param,
List<Serializable> defValues, Map<String, Object> parameterValues) throws QueryException {
if (param.getSelection().equals(QueryParameter.SINGLE_SELECTION)) {
parameterValues.put(pa... | java |
public static void initStaticDefaultParameterValues(QueryParameter param,
Map<String, Object> parameterValues) throws QueryException {
List<Serializable> defValues;
if ((param.getDefaultValues() != null) && (param.getDefaultValues().size() > 0)) {
... | java |
public static void initAllRuntimeParameterValues(Connection conn, QueryParameter param, Map<String,QueryParameter> map,
Map<String, Object> parameterValues) throws QueryException {
List<IdName> allValues = new ArrayList<IdName>();
if ((param.getSou... | java |
public static void initStaticNotHiddenDefaultParameterValues(Report report,
Map<String, Object> parameterValues) throws QueryException {
Map<String, QueryParameter> params = getUsedParametersMap(report);
for (QueryParameter qp : params.values())... | java |
public static Map<String, QueryParameter> toMap(List<QueryParameter> parameters) {
Map<String, QueryParameter> map = new HashMap<String, QueryParameter>();
for (QueryParameter qp : parameters) {
map.put(qp.getName(), qp);
}
return map;
} | java |
public static Object getParameterValueFromStringWithPattern(String parameterClass, String value, String pattern) throws Exception {
if (pattern == null) {
return getParameterValueFromString(parameterClass, value);
} else {
if (QueryParameter.DATE_VALUE.equals(parameterClass) ||
QueryParameter.TIME... | java |
public static Map<String, QueryParameter> intersectParametersMap(List<Report> reports) {
Map<String, QueryParameter> map = new LinkedHashMap<String, QueryParameter>();
if ((reports == null) || (reports.size() == 0)) {
return map;
}
if (reports.size() == 1) {
return getUsedParametersMap(r... | java |
public int addSection (String label, ListModel model)
{
add(new JLabel(label));
add(new JList(model));
return getSectionCount()-1;
} | java |
public JList getSectionList (int index)
{
@SuppressWarnings("unchecked") JList list = (JList)getComponent(index*2+1);
return list;
} | java |
public void toggleCollapsed (int index)
{
JList list = getSectionList(index);
list.setVisible(!list.isVisible());
} | java |
public Constructor<?> findConstructor (Class<?>[] parameterTypes)
throws NoSuchMethodException
{
// make sure the constructor list is loaded
maybeLoadConstructors();
if (parameterTypes == null) {
parameterTypes = new Class<?>[0];
}
return (Constructor<?>... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.