code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
private void unwrapIO(RedmineException orig, String tag) throws IOException {
Throwable e = orig;
while (e != null) {
if (e instanceof MarkedIOException) {
final MarkedIOException marked = (MarkedIOException) e;
if (tag.equals(marked.getTag()))
throw marked.getIOException();
}
e = e.getCause()... | java |
public void addMembership(Membership membership) throws RedmineException {
final Project project = membership.getProject();
if (project == null)
throw new IllegalArgumentException("Project must be set");
if (membership.getUser() == null)
throw new IllegalArgumentException("User must be set");
transport.ad... | java |
public void export(Writer output, UndirectedGraph<V, E> g) {
export(output, g, false);
} | java |
public void export(Writer output, DirectedGraph<V, E> g) {
export(output, g, true);
} | java |
public void set(final Iterable<String> strings) {
checkNotNull(strings);
candidates.clear();
addAll(strings);
} | java |
public void addAll(final Iterable<String> strings) {
checkNotNull(strings);
for (String string : strings) {
add(string);
}
} | java |
public void add(final String string) {
checkNotNull(string);
candidates.put(string, candidate(string));
} | java |
public void add(final String string, final Candidate candidate) {
checkNotNull(string);
checkNotNull(candidate);
candidates.put(string, candidate);
} | java |
protected void initNextPath (long initStamp, long tickStamp)
{
if (_paths.size() == 0) {
_pable.pathCompleted(tickStamp);
} else {
_curPath = _paths.remove(0);
_lastInit = initStamp;
_curPath.init(_pableRep, initStamp);
_curPath.tick(_pab... | java |
public static String getStatus(String elementName, long percentage, double speed, String speedUnit, Duration eta) {
StringBuilder sb = new StringBuilder(getBar(percentage));
sb.append((long) speed);
if (elementName != null) {
sb.append(" ").append(elementName);
}
sb.a... | java |
protected static String getBar(long percentage) {
StringBuilder sb = new StringBuilder();
sb.append(percentage);
sb.append("% [");
for (int i = 0; i < 100; i++) {
if (percentage == 100 || i < percentage - 1) {
sb.append("=");
} else if (i == percen... | java |
@Override
public void processConnect(WebSocketChannel channel, WSURI location, String[] protocols) {
nextHandler.processConnect(channel, location, protocols);
} | java |
@Override
public synchronized void processAuthorize(WebSocketChannel channel, String authorizeToken) {
nextHandler.processAuthorize(channel, authorizeToken);
} | java |
public tsfile_data data(TimeSeriesCollection ts_data) {
final dictionary_delta dict_delta = new dictionary_delta();
dict_delta.gdd = new path_dictionary_delta[0];
dict_delta.mdd = new path_dictionary_delta[0];
dict_delta.sdd = new strval_dictionary_delta[0];
dict_delta.tdd = new ... | java |
public static <T> Iterable<T> simpleIterable(final Iterable<T> iterable) {
requireNonNull(iterable);
return () -> iterable.iterator();
} | java |
public static <T> Iterable<T> distinct(final Iterable<T> iterable) {
requireNonNull(iterable);
return () -> Iterators2.distinct(iterable.iterator());
} | java |
public String encodeAuthAmqPlain(String username, String password)
{
AmqpBuffer bytes = new AmqpBuffer();
bytes.putShortString("LOGIN");
bytes.putTypeIdentifier("Longstr");
bytes.putLongString(username);
bytes.putShortString("PASSWORD");
bytes.putTypeIdentifi... | java |
private Arg[] getMethodArguments(List<Parameter> param)
{
Arg[] val = new Arg[param.size()];
for (int i = 0; i < param.size(); i++)
{
String type = param.get(i).type;
Arg arg = new Arg();
arg.type = type;
arg.name = param.get(i).name... | java |
public AmqpFrame getFrame()
{
int pos = this.position();
AmqpMethod method = new AmqpMethod();
int classIndex;
AmqpFrame frame = new AmqpFrame();
// If there is at least one Frame in the buffer, attempt to decode it.
if (this.remaining() ... | java |
AmqpBuffer putMethodArguments(Object[] args, List<Parameter> formalParams)
{
for (int i = 0; i < formalParams.size(); i++)
{
String type = formalParams.get(i).type;
if (type == null)
{
throw new IllegalStateException("Unk... | java |
@Override
public void update (Graphics g)
{
Shape clip = g.getClip();
Rectangle dirty;
if (clip != null) {
dirty = clip.getBounds();
} else {
dirty = getRootPane().getBounds();
// account for our frame insets
Insets insets = getInse... | java |
public static <T extends Serializable> T deserialize(byte[] bytes) throws IOException, ClassNotFoundException {
return deserialize(bytes, false);
} | java |
public PushProcessorPipeline build(List<PushProcessorSupplier> processor_suppliers) throws Exception {
ApiServer api = null;
PushMetricRegistryInstance registry = null;
final List<PushProcessor> processors = new ArrayList<>(processor_suppliers.size());
try {
final EndpointReg... | java |
public static BufferedImage createCompatibleImage (BufferedImage source, int width, int height)
{
WritableRaster raster = source.getRaster().createCompatibleWritableRaster(width, height);
return new BufferedImage(source.getColorModel(), raster, false, null);
} | java |
public static BufferedImage createErrorImage (int width, int height)
{
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED);
Graphics2D g = (Graphics2D)img.getGraphics();
g.setColor(Color.red);
Label l = new Label("Error");
l.layout(g);
... | java |
public static BufferedImage recolorImage (BufferedImage image, Colorization[] zations)
{
ColorModel cm = image.getColorModel();
if (!(cm instanceof IndexColorModel)) {
throw new RuntimeException(Logger.format(
"Unable to recolor images with non-index color model", "cm", c... | java |
public static void tileImage (Graphics2D gfx, Mirage image, int x, int y, int width, int height)
{
int iwidth = image.getWidth(), iheight = image.getHeight();
int xnum = width / iwidth, xplus = width % iwidth;
int ynum = height / iheight, yplus = height % iheight;
Shape oclip = gfx.g... | java |
public static void tileImageAcross (Graphics2D gfx, Mirage image, int x, int y, int width)
{
tileImage(gfx, image, x, y, width, image.getHeight());
} | java |
public static void tileImageDown (Graphics2D gfx, Mirage image, int x, int y, int height)
{
tileImage(gfx, image, x, y, image.getWidth(), height);
} | java |
public static BufferedImage createTracedImage (
ImageCreator isrc, BufferedImage src, Color tcolor, int thickness)
{
return createTracedImage(isrc, src, tcolor, thickness, 1.0f, 1.0f);
} | java |
protected static boolean bordersNonTransparentPixel (
BufferedImage data, int wid, int hei, boolean[] traced, int x, int y)
{
// check the three-pixel row above the pixel
if (y > 0) {
for (int rxx = x - 1; rxx <= x + 1; rxx++) {
if (rxx < 0 || rxx >= wid || traced... | java |
public static BufferedImage composeMaskedImage (
ImageCreator isrc, BufferedImage mask, BufferedImage base)
{
int wid = base.getWidth();
int hei = base.getHeight();
Raster maskdata = mask.getData();
Raster basedata = base.getData();
// create a new image using the r... | java |
public static BufferedImage composeMaskedImage (
ImageCreator isrc, Shape mask, BufferedImage base)
{
int wid = base.getWidth();
int hei = base.getHeight();
// alternate method for composition:
// 1. create WriteableRaster with base data
// 2. test each pixel with ma... | java |
public static void computeTrimmedBounds (BufferedImage image, Rectangle tbounds)
{
// this could be more efficient, but it's run as a batch process and doesn't really take
// that long anyway
int width = image.getWidth(), height = image.getHeight();
int firstrow = -1, lastrow = -1, ... | java |
public static long getEstimatedMemoryUsage (Raster raster)
{
// we assume that the data buffer stores each element in a byte-rounded memory element;
// maybe the buffer is smarter about things than this, but we're better to err on the safe
// side
DataBuffer db = raster.getDataBuffer... | java |
public static long getEstimatedMemoryUsage (Iterator<BufferedImage> iter)
{
long size = 0;
while (iter.hasNext()) {
BufferedImage image = iter.next();
size += getEstimatedMemoryUsage(image);
}
return size;
} | java |
protected static GraphicsConfiguration getDefGC ()
{
if (_gc == null) {
// obtain information on our graphics environment
try {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = env.getDefaultScreenDevice(... | java |
public void getIntersectingSprites (List<Sprite> list, Shape shape)
{
int size = _sprites.size();
for (int ii = 0; ii < size; ii++) {
Sprite sprite = _sprites.get(ii);
if (sprite.intersects(shape)) {
list.add(sprite);
}
}
} | java |
public void getHitSprites (List<Sprite> list, int x, int y)
{
for (int ii = _sprites.size() - 1; ii >= 0; ii--) {
Sprite sprite = _sprites.get(ii);
if (sprite.hitTest(x, y)) {
list.add(sprite);
}
}
} | java |
public Sprite getHighestHitSprite (int x, int y)
{
// since they're stored in lowest -> highest order..
for (int ii = _sprites.size() - 1; ii >= 0; ii--) {
Sprite sprite = _sprites.get(ii);
if (sprite.hitTest(x, y)) {
return sprite;
}
}
... | java |
public void removeSprites (Predicate<Sprite> pred)
{
int idxoff = 0;
for (int ii = 0, ll = _sprites.size(); ii < ll; ii++) {
Sprite sprite = _sprites.get(ii-idxoff);
if (pred.apply(sprite)) {
_sprites.remove(sprite);
sprite.invalidate();
... | java |
public void cancelMove ()
{
if (_path != null) {
Path oldpath = _path;
_path = null;
oldpath.wasRemoved(this);
if (_observers != null) {
_observers.apply(new CancelledOp(this, oldpath));
}
}
} | java |
public void pathCompleted (long timestamp)
{
Path oldpath = _path;
_path = null;
oldpath.wasRemoved(this);
if (_observers != null) {
_observers.apply(new CompletedOp(this, oldpath, timestamp));
}
} | java |
protected boolean tickPath (long tickStamp)
{
if (_path == null) {
return false;
}
// initialize the path if we haven't yet
if (_pathStamp == 0) {
_path.init(this, _pathStamp = tickStamp);
}
// it's possible that as a result of init() the pat... | java |
public void layout (Graphics2D gfx, SceneObject tipFor, Rectangle boundary)
{
layout(gfx, ICON_PAD, EXTRA_PAD);
bounds = new Rectangle(_size);
// locate the most appropriate tip layout
for (int ii = 0, ll = _layouts.size(); ii < ll; ii++) {
LayoutReg reg = _layouts.get(i... | java |
public static void registerTipLayout (String prefix, TipLayout layout)
{
LayoutReg reg = new LayoutReg();
reg.prefix = prefix;
reg.layout = layout;
_layouts.insertSorted(reg);
} | java |
public static boolean isLeaf(Node node) {
return node instanceof Leaf || node.children() == null || node.children().size() == 0;
} | java |
public static boolean isEmpty(Node node) {
return (node == null || (node.children() != null && node.children().size() == 0));
} | java |
public static boolean parentContainsOnlyLeaves(ParentNode parentNode) {
for (Node child : parentNode.children()) {
if (!isLeaf(child)) return false;
}
return true;
} | java |
public static Criteria criteriaFromNode(Node node, Comparator rangeComparator) {
return criteriaFromNode(node, rangeComparator, null);
} | java |
public static void renameTileSet (
String mapPath, String oldName, String newName)
throws PersistenceException
{
MapFileTileSetIDBroker broker =
new MapFileTileSetIDBroker(new File(mapPath));
if (!broker.renameTileSet(oldName, newName)) {
throw new Persistence... | java |
protected TrimmedTileSet trim (TileSet aset, OutputStream fout) throws IOException
{
return TrimmedTileSet.trimTileSet(aset, fout);
} | java |
protected void saveBroker (File mapfile, HashMapIDBroker broker)
throws RuntimeException
{
// bail if the broker wasn't modified
if (!broker.isModified()) {
return;
}
try {
BufferedWriter bout = new BufferedWriter(new FileWriter(mapfile));
... | java |
private static GroupName nameFromObjectName(ObjectName obj_name, NamedResolverMap resolvedMap) {
String name = obj_name.getKeyProperty("name");
String type = obj_name.getKeyProperty("type");
String domain = obj_name.getDomain();
Map<String, MetricValue> tags = obj_name.getKeyPropertyLis... | java |
static boolean isSorted(Iterable<? extends TimeSeriesCollection> tscIterable) {
final Iterator<? extends TimeSeriesCollection> iter = tscIterable.iterator();
if (!iter.hasNext()) return true; // Empty collection is ordered.
DateTime timestamp = iter.next().getTimestamp();
while (iter.ha... | java |
public void resolve (Observer observer)
{
// if we were waiting to unload, cancel that
if (_state == UNLOADING) {
_state = LOADED;
_manager.restoreClip(this);
}
// if we're already loaded, this is easy
if (_state == LOADED) {
if (observer ... | java |
public void dispose ()
{
if (_buffer != null) {
// if there are sources bound to this buffer, we must wait
// for them to be unbound
if (_bound > 0) {
_state = UNLOADING;
return;
}
// free up our buffer
... | java |
protected boolean bind (Clip clip)
{
AL10.alGetError(); // throw away any unchecked error prior to an op we want to check
_buffer.setData(clip.format, clip.data, clip.frequency);
int errno = AL10.alGetError();
if (errno != AL10.AL_NO_ERROR) {
log.warning("Failed to bind c... | java |
protected void failed ()
{
if (_buffer != null) {
_buffer.delete();
_buffer = null;
}
_state = UNLOADED;
_observers.apply(new ObserverList.ObserverOp<Observer>() {
public boolean apply (Observer observer) {
observer.clipFailed(Clip... | java |
protected void createVolatileImage ()
{
// release any previous volatile image we might hold
if (_image != null) {
_image.flush();
}
// create a new, compatible, volatile image
// _image = _imgr.createVolatileImage(
// _bounds.width, _bounds.height, g... | java |
public boolean askBoolean(final String question) {
checkNotNull(question);
log.trace("Ask boolean; question={}", question);
String result = readLine(String.format("%s (yes/no): ", question));
return result.equalsIgnoreCase("yes");
} | java |
public void addPressCommand (int keyCode, String command, int rate)
{
addPressCommand(keyCode, command, rate, DEFAULT_REPEAT_DELAY);
} | java |
public void addPressCommand (int keyCode, String command, int rate, long repeatDelay)
{
KeyRecord krec = getKeyRecord(keyCode);
krec.pressCommand = command;
krec.repeatRate = rate;
krec.repeatDelay = repeatDelay;
} | java |
public void addReleaseCommand (int keyCode, String command)
{
KeyRecord krec = getKeyRecord(keyCode);
krec.releaseCommand = command;
} | java |
protected KeyRecord getKeyRecord (int keyCode)
{
KeyRecord krec = _keys.get(keyCode);
if (krec == null) {
krec = new KeyRecord();
_keys.put(keyCode, krec);
}
return krec;
} | java |
public void addSprite (Sprite sprite)
{
_metamgr.addSprite(sprite);
if (((sprite instanceof ActionSprite) ||
(sprite instanceof HoverSprite)) && (_actionSpriteCount++ == 0)) {
if (_actionHandler == null) {
_actionHandler = createActionSpriteHandler();
... | java |
public void removeSprite (Sprite sprite)
{
_metamgr.removeSprite(sprite);
if (((sprite instanceof ActionSprite) ||
(sprite instanceof HoverSprite)) && (--_actionSpriteCount == 0)) {
removeMouseListener(_actionHandler);
removeMouseMotionListener(_actionHandler);
... | java |
public void clearSprites ()
{
_metamgr.clearSprites();
if (_actionHandler != null) {
removeMouseListener(_actionHandler);
removeMouseMotionListener(_actionHandler);
_actionSpriteCount = 0;
}
} | java |
public void tick (long tickStamp)
{
if (_metamgr.isPaused()) {
return;
}
// let derived classes do their business
willTick(tickStamp);
// tick our meta manager which will tick our sprites and animations
_metamgr.tick(tickStamp);
// let derived c... | java |
public void addObscurer (Obscurer obscurer) {
if (_obscurerList == null) {
_obscurerList = Lists.newArrayList();
}
_obscurerList.add(obscurer);
} | java |
protected void addObscurerDirtyRegions (boolean changedOnly)
{
if (_obscurerList != null) {
for (Obscurer obscurer : _obscurerList) {
Rectangle obscured = obscurer.getObscured(changedOnly);
if (obscured != null) {
Point pt = new Point(obscured.... | java |
protected void paintDirtyRect (Graphics2D gfx, Rectangle rect)
{
// paint the behind the scenes stuff
paintBehind(gfx, rect);
// paint back sprites and animations
paintBits(gfx, AnimationManager.BACK, rect);
// paint the between the scenes stuff
paintBetween(gfx, re... | java |
public static String getEntityEncoding(HttpEntity entity) {
final Header header = entity.getContentEncoding();
if (header == null)
return null;
return header.getValue();
} | java |
public static String getCharset(HttpEntity entity) {
final String guess = EntityUtils.getContentCharSet(entity);
return guess == null ? HTTP.DEFAULT_CONTENT_CHARSET : guess;
} | java |
public Tuple<String, Boolean> decodeFormat (int type, String format)
{
boolean quotes = true;
switch (placeOf(type)) {
// derived classes may wish to change the format here based on the place
case PLACE:
switch (modeOf(type)) {
case EMOTE:
quot... | java |
public int decodeType (String localtype)
{
if (ChatCodes.USER_CHAT_TYPE.equals(localtype)) {
return TELL;
} else if (ChatCodes.PLACE_CHAT_TYPE.equals(localtype)) {
return PLACE;
} else {
return 0;
}
} | java |
public int adjustTypeByMode (int mode, int type)
{
switch (mode) {
case ChatCodes.DEFAULT_MODE:
return type | SPEAK;
case ChatCodes.EMOTE_MODE:
return type | EMOTE;
case ChatCodes.THINK_MODE:
return type | THINK;
case ChatCodes.SHOUT_MODE:
... | java |
public Color getOutlineColor (int type)
{
switch (type) {
case BROADCAST:
return BROADCAST_COLOR;
case TELL:
return TELL_COLOR;
case TELLFEEDBACK:
return TELLFEEDBACK_COLOR;
case INFO:
return INFO_COLOR;
case FEEDBACK:
... | java |
public SparseMisoSceneModel parseScene (String path)
throws IOException, SAXException
{
_model = null;
_digester.push(this);
FileInputStream stream = null;
try {
stream = new FileInputStream(path);
_digester.parse(stream);
} finally {
... | java |
public static PathMatcher valueOf(String str) throws ParseException {
try {
return valueOf(new StringReader(str));
} catch (IOException ex) {
throw new IllegalStateException("StringReader IO error?", ex);
}
} | java |
public static PathMatcher valueOf(Reader reader) throws IOException, ParseException {
class DescriptiveErrorListener extends BaseErrorListener {
public List<String> errors = new ArrayList<>();
@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSym... | java |
public List<ChannelListener> getChannelListeners() {
if (changes == null) {
return (List<ChannelListener>)Collections.EMPTY_LIST;
}
List<EventListener> listeners = changes.getListenerList(AMQP);
if ((listeners == null) || listeners.isEmpty()) {
return (List<Chann... | java |
AmqpChannel openChannel() {
if (readyState == ReadyState.OPEN) {
// If the channel is already open, just bail.
return this;
}
// try {
Object[] args = {""};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg =... | java |
public AmqpChannel flowChannel(boolean active) {
isFlowOn = active;
Object[] args = {active};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodId = "20" + "20";
String methodName = "flowChannel";
AmqpMethod amqpMethod = Me... | java |
public AmqpChannel closeChannel(int replyCode, String replyText, int classId, int methodId1) {
if (readyState == ReadyState.CLOSED) {
return this;
}
Object[] args = {replyCode, replyText, classId, methodId1};
WrappedByteBuffer bodyArg = null;
HashMap<String, ... | java |
private AmqpChannel closeOkChannel() {
if (readyState == ReadyState.CLOSED) {
// If the channel has been closed, just bail.
return this;
}
Object[] args = {};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
St... | java |
public AmqpChannel deleteQueue(String queue, boolean ifUnused, boolean ifEmpty, boolean noWait) {
Object[] args = {0, queue, ifUnused, ifEmpty, noWait};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "deleteQueue";
String methodI... | java |
public AmqpChannel unbindQueue(String queue, String exchange, String routingKey, AmqpArguments arguments) {
Object[] args = {0, queue, exchange, routingKey, arguments};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "unbindQueue";
... | java |
public AmqpChannel qosBasic(int prefetchSize, int prefetchCount, boolean global) {
Object[] args = {prefetchSize, prefetchCount, global};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "qosBasic";
String methodId = "60" + "10";
... | java |
public AmqpChannel publishBasic(ByteBuffer body, AmqpProperties properties, String exchange, String routingKey, boolean mandatory, boolean immediate) {
@SuppressWarnings("unchecked")
Map<String, Object> amqpProps = (Map<String, Object>)Collections.EMPTY_MAP;
if (properties != null) {
... | java |
public AmqpChannel getBasic(String queue, boolean noAck) {
Object[] args = {0, queue, noAck};
WrappedByteBuffer bodyArg = null;
HashMap<String, Object> headersArg = null;
String methodName = "getBasic";
String methodId = "60" + "70";
AmqpMethod amqpMethod = MethodLookup.... | java |
private void fireOnOpen(ChannelEvent e) {
if (readyState == ReadyState.OPEN) {
// If the channel has already been opened, then we should not fire
// any events.
return;
}
readyState = ReadyState.OPEN;
List<EventListener> listeners = changes.ge... | java |
private void fireOnDeclareExchange(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onDeclareExchange(e);
}
} | java |
private void fireOnDeclareQueue(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onDeclareQueue(e);
}
} | java |
private void fireOnBindQueue(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onBindQueue(e);
}
} | java |
private void fireOnConsumeBasic(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onConsumeBasic(e);
}
} | java |
private void fireOnCommitTransaction(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onCommit(e);
}
} | java |
private void fireOnRollbackTransaction(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onRollback(e);
}
} | java |
private void fireOnSelectTransaction(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onSelect(e);
}
} | java |
private void fireOnMessage(ChannelEvent e) {
List<EventListener> listeners = changes.getListenerList(AMQP);
for (EventListener listener : listeners) {
ChannelListener amqpListener = (ChannelListener)listener;
amqpListener.onMessage(e);
}
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.