id
stringlengths
7
14
text
stringlengths
1
106k
726694_1
public boolean intersects(Box2D bb) { return Math.max(min.getX(), bb.getMin().getX()) <= Math.min(max.getX(), bb.getMax().getX()) && Math.max(min.getY(), bb.getMin().getY()) <= Math.min(max.getY(), bb.getMax().getY()); }
726694_2
public boolean contains(Vector2 position) { return this.valid() && (position.getX() >= this.getMin().getX() && position.getX() <= this.getMax().getX() && position.getY() >= this.getMin().getY() && position.getY() <= this.getMax() .getY()); }
726694_3
public Vector2 subtract(Vector2 nodePosition) { return new Vector2(this.getX() - nodePosition.getX(), this.getY() - nodePosition.getY()); }
726694_4
public Vector2 add(Vector2 rhs) { return new Vector2(this.getX() + rhs.getX(), this.getY() + rhs.getY()); }
726694_5
public Vector2 rotate(double angle) { double x = this.getX() * Math.cos(angle) - this.getY() * Math.sin(angle); double y = this.getX() * Math.sin(angle) + this.getY() * Math.cos(angle); return new Vector2(x, y); }
726694_6
public double distance(Vector2 other) { return Math.sqrt(this.distanceSquared(other)); }
726694_7
public double distanceSquared(Vector2 other) { return ((this.getX() - other.getX()) * (this.getX() - other.getX())) + ((this.getY() - other.getY()) * (this.getY() - other.getY())); }
726694_8
public double dot(Vector2 v) { return this.x * v.x + this.y * v.y; }
726694_9
}
74217_10
public ReflectionField locateById(Class<?> clazz, String id) { for (java.lang.reflect.Field field : locateAnnotated(clazz, Field.class)) { String annotationValue = field.getAnnotation(Field.class).value(); if (!isEmpty(annotationValue) && id.equals(annotationValue)) { return new Reflecti...
74217_11
public ReflectionField locateById(Class<?> clazz, String id) { for (java.lang.reflect.Field field : locateAnnotated(clazz, Field.class)) { String annotationValue = field.getAnnotation(Field.class).value(); if (!isEmpty(annotationValue) && id.equals(annotationValue)) { return new Reflecti...
74217_12
public ReflectionField locateById(Class<?> clazz, String id) { for (java.lang.reflect.Field field : locateAnnotated(clazz, Field.class)) { String annotationValue = field.getAnnotation(Field.class).value(); if (!isEmpty(annotationValue) && id.equals(annotationValue)) { return new Reflecti...
74217_13
public ReflectionField locateById(Class<?> clazz, String id) { for (java.lang.reflect.Field field : locateAnnotated(clazz, Field.class)) { String annotationValue = field.getAnnotation(Field.class).value(); if (!isEmpty(annotationValue) && id.equals(annotationValue)) { return new Reflecti...
74217_14
public List<String> gatherFieldIds(Class<?> clazz) { List<String> fieldNames = new ArrayList<String>(); for (java.lang.reflect.Field field : locateAnnotated(clazz, Field.class)) { String id = field.getAnnotation(Field.class).value(); if (id == null || id.trim().length() == 0) { id = ...
74217_15
public int parseDecimalPlaces(String pattern) { if (pattern.toLowerCase().indexOf("v") == -1) { throw new IllegalArgumentException(MessageFormat.format(NOT_A_DECIMAL_PATTERN, new Object[]{pattern})); } String decimal = pattern.split("v|V")[1]; if (Pattern.matches(NO_MULTIPLIER.pattern(), decimal...
74217_16
public CobolFieldType resolve(String pattern) { if (Pattern.matches(CobolFieldPatternValidator.ALPHANUMERIC_PATTERN, pattern)) { return CobolFieldType.ALPHA_NUMERIC; } else if (Pattern.matches(CobolFieldPatternValidator.INTEGER_PATTERN, pattern)) { return CobolFieldType.INTEGER; } else if (P...
74217_17
public CobolFieldDefinition build(CobolFieldInfo fieldInfo, PaddingDescriptor paddingDescriptor) { if (fieldInfo.getType() == CobolFieldType.DECIMAL) return new DecimalFieldDefinition(fieldInfo.getName(), fieldInfo.getPosition(), fieldInfo.getPattern(), paddingDescriptor); else if (fieldInfo.getType() =...
74217_18
public CobolFieldDefinition build(CobolFieldInfo fieldInfo, PaddingDescriptor paddingDescriptor) { if (fieldInfo.getType() == CobolFieldType.DECIMAL) return new DecimalFieldDefinition(fieldInfo.getName(), fieldInfo.getPosition(), fieldInfo.getPattern(), paddingDescriptor); else if (fieldInfo.getType() =...
74217_19
public CobolFieldDefinition build(CobolFieldInfo fieldInfo, PaddingDescriptor paddingDescriptor) { if (fieldInfo.getType() == CobolFieldType.DECIMAL) return new DecimalFieldDefinition(fieldInfo.getName(), fieldInfo.getPosition(), fieldInfo.getPattern(), paddingDescriptor); else if (fieldInfo.getType() =...
74217_20
public boolean validate(String pattern) { List patterns = Arrays.asList(new String[]{ALPHANUMERIC_PATTERN, INTEGER_PATTERN, DECIMAL_PATTERN}); Iterator it = patterns.iterator(); while (it.hasNext()) { if (Pattern.matches((String) it.next(), pattern)) { return true; } } re...
747707_0
public static String createLine(RecordType recordType, int address, byte[] data) { if(recordType != DATA && recordType != END_OF_FILE) { throw new RuntimeException("Un-supported record type: " + recordType + "."); } StringBuilder builder = new StringBuilder(9 + data.length * 2); builder.append('...
747707_1
public static IntelHexPacket parseLine(int lineNo, String line) throws IOException { if (line.length() < 9) { throw new IOException("line " + lineNo + ": the line must contain at least 9 characters."); } lineNo++; char startCode = line.charAt(0); int count = parseInt(line.substring(1, 3), 16...
747707_2
public static IntelHexPacket parseLine(int lineNo, String line) throws IOException { if (line.length() < 9) { throw new IOException("line " + lineNo + ": the line must contain at least 9 characters."); } lineNo++; char startCode = line.charAt(0); int count = parseInt(line.substring(1, 3), 16...
747707_3
public static List<IntelHexPacket> openIntelHexFile(final File file) throws IOException { return openIntelHexFile(new FileInputStream(file)); }
747707_4
public static void writeBytes(PrintStream print, byte[] bytes) { writeBytes(print, bytes, 0, bytes.length); }
747707_5
public static void writeBytes(PrintStream print, byte[] bytes) { writeBytes(print, bytes, 0, bytes.length); }
747707_6
public static void writeBytes(PrintStream print, byte[] bytes) { writeBytes(print, bytes, 0, bytes.length); }
747707_7
public static void writeBytes(PrintStream print, byte[] bytes) { writeBytes(print, bytes, 0, bytes.length); }
747707_8
public static void writeBytes(PrintStream print, byte[] bytes) { writeBytes(print, bytes, 0, bytes.length); }
747707_9
public static void writeBytes(PrintStream print, byte[] bytes) { writeBytes(print, bytes, 0, bytes.length); }
749137_0
public static String getCleanedServletPath(String fullServletPath) { if (fullServletPath.equalsIgnoreCase("/*")) return ""; Matcher matcher = SERVLET_PATH_PATTERN.matcher(fullServletPath); // It should not happen if the servlet path is valid if (!matcher.find()) return fullServletPath; String servle...
749137_1
public AtmosphereInterceptorWriter interceptor(AsyncIOInterceptor filter) { if (!filters.contains(filter)) { logger.trace("Adding AsyncIOInterceptor {}", filter.getClass().getName()); filters.addLast(filter); reversedFilters.addFirst(filter); } return this; }
749137_2
@Override public synchronized Broadcaster get() { return get(clazz.getSimpleName() + "-" + config.uuidProvider().generateUuid()); }
749137_3
@Override public synchronized Broadcaster get() { return get(clazz.getSimpleName() + "-" + config.uuidProvider().generateUuid()); }
749137_4
@Override public synchronized Broadcaster get() { return get(clazz.getSimpleName() + "-" + config.uuidProvider().generateUuid()); }
749137_5
@Override public boolean add(Broadcaster b, Object id) { return (store.put(id, b) == null); }
749137_6
@Override public boolean remove(Broadcaster b, Object id) { boolean removed = store.remove(id, b); if (removed && logger.isDebugEnabled()) { logger.debug("Removing Broadcaster {} factory size now {} ", id, store.size()); } return removed; }
749137_7
@Override public <T extends Broadcaster> T lookup(Class<T> c, Object id) { return lookup(c, id, false); }
749137_8
@Override public <T extends Broadcaster> T lookup(Class<T> c, Object id) { return lookup(c, id, false); }
749137_9
@Override public <T extends Broadcaster> T lookup(Class<T> c, Object id) { return lookup(c, id, false); }
762097_0
public synchronized Serializable generate(final SessionImplementor session, Object obj) { // maxLo < 1 indicates a hilo generator with no hilo :? if ( maxLo < 1 ) { //keep the behavior consistent even for boundary usages IntegralDataTypeHolder value = null; while ( value == null || value.lt( 0 ) ) { value = ...
762097_1
public synchronized Serializable generate(final SessionImplementor session, Object obj) { // maxLo < 1 indicates a hilo generator with no hilo :? if ( maxLo < 1 ) { //keep the behavior consistent even for boundary usages IntegralDataTypeHolder value = null; while ( value == null || value.lt( 0 ) ) { va...
762097_2
public static String renderWhereStringTemplate(String sqlWhereString, Dialect dialect, SQLFunctionRegistry functionRegistry) { return renderWhereStringTemplate(sqlWhereString, TEMPLATE, dialect, functionRegistry); }
762097_3
public static String renderWhereStringTemplate(String sqlWhereString, Dialect dialect, SQLFunctionRegistry functionRegistry) { return renderWhereStringTemplate(sqlWhereString, TEMPLATE, dialect, functionRegistry); }
762097_4
@Override public SessionFactory buildSessionFactory() { return new SessionFactoryImpl(metadata, options, null ); }
762097_5
void applyDefaults(SchemaAware schemaAware, EntityMappingsMocker.Default defaults) { if ( hasSchemaOrCatalogDefined( defaults ) ) { if ( StringHelper.isEmpty( schemaAware.getSchema() ) ) { schemaAware.setSchema( defaults.getSchema() ); } if ( StringHelper.isEmpty( schemaAware.getCatalog() ) ) { schemaAware...
762097_6
void applyDefaults(SchemaAware schemaAware, EntityMappingsMocker.Default defaults) { if ( hasSchemaOrCatalogDefined( defaults ) ) { if ( StringHelper.isEmpty( schemaAware.getSchema() ) ) { schemaAware.setSchema( defaults.getSchema() ); } if ( StringHelper.isEmpty( schemaAware.getCatalog() ) ) { schemaAware...
762097_7
void applyDefaults(SchemaAware schemaAware, EntityMappingsMocker.Default defaults) { if ( hasSchemaOrCatalogDefined( defaults ) ) { if ( StringHelper.isEmpty( schemaAware.getSchema() ) ) { schemaAware.setSchema( defaults.getSchema() ); } if ( StringHelper.isEmpty( schemaAware.getCatalog() ) ) { schemaAware...
762097_8
void applyDefaults(SchemaAware schemaAware, EntityMappingsMocker.Default defaults) { if ( hasSchemaOrCatalogDefined( defaults ) ) { if ( StringHelper.isEmpty( schemaAware.getSchema() ) ) { schemaAware.setSchema( defaults.getSchema() ); } if ( StringHelper.isEmpty( schemaAware.getCatalog() ) ) { schemaAware...
762097_9
public static void bind(AnnotationBindingContext bindingContext) { List<AnnotationInstance> annotations = bindingContext.getIndex() .getAnnotations( HibernateDotNames.FETCH_PROFILE ); for ( AnnotationInstance fetchProfile : annotations ) { bind( bindingContext.getMetadataImplementor(), fetchProfile ); } annota...
763770_0
@Override public AssocModelImpl fetchAssoc(long assocId) { return buildAssoc(fetchAssocNode(assocId)); }
763770_1
@Override public void deleteAssoc(long assocId) { // 1) update DB Node assocNode = fetchAssocNode(assocId); // delete the 2 player relationships for (Relationship rel : fetchRelationships(assocNode)) { rel.delete(); } // assocNode.delete(); // // 2) update index removeAss...
763770_2
@Override public List<TopicModelImpl> queryTopicsFulltext(String key, Object value) { if (key == null) { key = KEY_FULLTEXT; } if (value == null) { throw new IllegalArgumentException("Tried to call queryTopicsFulltext() with a null value Object (key=\"" + key + "\")"); } ...
763770_3
@Override public List<TopicModelImpl> queryTopicsFulltext(String key, Object value) { if (key == null) { key = KEY_FULLTEXT; } if (value == null) { throw new IllegalArgumentException("Tried to call queryTopicsFulltext() with a null value Object (key=\"" + key + "\")"); } ...
763770_4
@Override public List<TopicModelImpl> queryTopics(String key, Object value) { return buildTopics(topicIndex.query(key, value)); }
763770_5
@Override public TopicModelImpl fetchTopic(long topicId) { return buildTopic(fetchTopicNode(topicId)); }
763770_6
@Override public Iterable<TopicModelImpl> fetchAllTopics() { return new TopicModelIterable(this); }
763770_7
@Override public Iterable<AssocModelImpl> fetchAllAssocs() { return new AssocModelIterable(this); }
763770_8
@Override public List<TopicModelImpl> fetchTopicsByProperty(String propUri, Object propValue) { return buildTopics(queryIndexByProperty(topicIndex, propUri, propValue)); }
763770_9
@Override public List<TopicModelImpl> fetchTopicsByPropertyRange(String propUri, Number from, Number to) { return buildTopics(queryIndexByPropertyRange(topicIndex, propUri, from, to)); }
766240_0
@Override public V getView() { // Previously we enforced that the presenter was bound, but this led to a lot // of false positives where: // 1. Presenter is bound, AJAX request fires in onBind() // 2. User clicks back, presenter is unbound // 3. AJAX response, fires onResult(), which tries to call getView() ...
766240_1
public void add(FormLine line) { formLines.add(line); line.bind(this, all, binder); renderNeeded(); }
766240_2
public PropertyGroup allValid() { return all; }
766240_3
public void focusFirstLine() { if (formLines.size() > 0) { formLines.get(0).focus(); } }
766240_4
public void add(FormLine line) { formLines.add(line); line.bind(this, all, binder); renderNeeded(); }
766240_5
public void add(FormLine line) { formLines.add(line); line.bind(this, all, binder); renderNeeded(); }
766240_6
public void add(FormLine line) { formLines.add(line); line.bind(this, all, binder); renderNeeded(); }
766240_7
public void fireAttached() { attached = true; AttachEvent.fire(this, true); }
766240_8
public static String humanize(final String camelCased) { String name = ""; for (final Iterator<String> i = split(camelCased).iterator(); i.hasNext();) { String part = capitalize(i.next().toLowerCase()); if (!part.isEmpty()) { name += part; if (i.hasNext()) { name += " "; } } ...
766240_9
public static String camelize(final String humanCased) { String name = ""; for (final Iterator<String> i = split(humanCased).iterator(); i.hasNext();) { name += capitalize(i.next().toLowerCase()); } return uncapitalize(name); }
766548_0
public boolean isWeekday(final Date inDate) { Calendar date = Calendar.getInstance(); date.setTime(inDate); return date.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && date.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY; }
766548_1
public boolean isWeekday(final Date inDate) { Calendar date = Calendar.getInstance(); date.setTime(inDate); return date.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && date.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY; }
766548_2
public boolean isWeekday(final Date inDate) { Calendar date = Calendar.getInstance(); date.setTime(inDate); return date.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && date.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY; }
766548_3
public boolean isWeekday(final Date inDate) { Calendar date = Calendar.getInstance(); date.setTime(inDate); return date.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && date.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY; }
766548_4
public boolean isWeekday(final Date inDate) { Calendar date = Calendar.getInstance(); date.setTime(inDate); return date.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && date.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY; }
766548_5
public boolean isWeekday(final Date inDate) { Calendar date = Calendar.getInstance(); date.setTime(inDate); return date.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && date.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY; }
766548_6
public boolean isWeekday(final Date inDate) { Calendar date = Calendar.getInstance(); date.setTime(inDate); return date.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && date.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY; }
766548_7
public int getWeekdayCountBetweenDates(final Date startDate, final Date endDate) { Calendar cal; Date start, end; long startMs, endMs; // normalize start date start = DateDayExtractor.getStartOfDay(startDate); // get and normalize the day before the end date cal = Calendar.getInstance(); ...
766548_8
public int getWeekdayCountBetweenDates(final Date startDate, final Date endDate) { Calendar cal; Date start, end; long startMs, endMs; // normalize start date start = DateDayExtractor.getStartOfDay(startDate); // get and normalize the day before the end date cal = Calendar.getInstance(); ...
766548_9
public int getWeekdayCountBetweenDates(final Date startDate, final Date endDate) { Calendar cal; Date start, end; long startMs, endMs; // normalize start date start = DateDayExtractor.getStartOfDay(startDate); // get and normalize the day before the end date cal = Calendar.getInstance(); ...
771158_0
@Override public int compare(Statement first, Statement second) { // Cannot use Statement.equals as it does not take Context into account, // but can check for reference equality (==) if (first == second) { return EQUAL; } if (first.getSubject().equals(second.getSubject())) { if (fir...
771158_1
@Override public int compare(Statement first, Statement second) { // Cannot use Statement.equals as it does not take Context into account, // but can check for reference equality (==) if (first == second) { return EQUAL; } if (first.getSubject().equals(second.getSubject())) { if (fir...
771158_2
@Override public int compare(Statement first, Statement second) { // Cannot use Statement.equals as it does not take Context into account, // but can check for reference equality (==) if (first == second) { return EQUAL; } if (first.getSubject().equals(second.getSubject())) { if (fir...
771158_3
@Override public int compare(Statement first, Statement second) { // Cannot use Statement.equals as it does not take Context into account, // but can check for reference equality (==) if (first == second) { return EQUAL; } if (first.getSubject().equals(second.getSubject())) { if (fir...
771158_4
@Override public int compare(Statement first, Statement second) { // Cannot use Statement.equals as it does not take Context into account, // but can check for reference equality (==) if (first == second) { return EQUAL; } if (first.getSubject().equals(second.getSubject())) { if (fir...
771158_5
@Override public int compare(Statement first, Statement second) { // Cannot use Statement.equals as it does not take Context into account, // but can check for reference equality (==) if (first == second) { return EQUAL; } if (first.getSubject().equals(second.getSubject())) { if (fir...
771158_6
@Override public int compare(Statement first, Statement second) { // Cannot use Statement.equals as it does not take Context into account, // but can check for reference equality (==) if (first == second) { return EQUAL; } if (first.getSubject().equals(second.getSubject())) { if (fir...
771158_7
@Override public int compare(Statement first, Statement second) { // Cannot use Statement.equals as it does not take Context into account, // but can check for reference equality (==) if (first == second) { return EQUAL; } if (first.getSubject().equals(second.getSubject())) { if (fir...
771158_8
@Override public int compare(Statement first, Statement second) { // Cannot use Statement.equals as it does not take Context into account, // but can check for reference equality (==) if (first == second) { return EQUAL; } if (first.getSubject().equals(second.getSubject())) { if (fir...
771158_9
@Override public int compare(Statement first, Statement second) { // Cannot use Statement.equals as it does not take Context into account, // but can check for reference equality (==) if (first == second) { return EQUAL; } if (first.getSubject().equals(second.getSubject())) { if (fir...
774619_0
@SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { // ///////////////////////////////////////////////////////////////////// // /...
774619_1
@SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { // ///////////////////////////////////////////////////////////////////// // /...
774619_2
@SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { // ///////////////////////////////////////////////////////////////////// // /...
774619_3
@SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { // ///////////////////////////////////////////////////////////////////// // /...
774619_4
@SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { // ///////////////////////////////////////////////////////////////////// // /...
774619_5
@SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { // ///////////////////////////////////////////////////////////////////// // /...
774619_6
@SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { // ///////////////////////////////////////////////////////////////////// // /...
774619_7
@SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { // ///////////////////////////////////////////////////////////////////// // /...
774619_8
@SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { // ///////////////////////////////////////////////////////////////////// // /...
774619_9
@SuppressWarnings("unchecked") public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { GeneralEnvelope requestedEnvelope = null; Rectangle dim = null; OverviewPolicy overviewPolicy=null; if (params != null) { // ///////////////////////////////////////////////////////////////////// // /...