_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q14700
MapElement.isContainerColorUsed
train
@Pure public boolean isContainerColorUsed() { final AttributeValue val = getAttributeCollection().getAttribute(ATTR_USE_CONTAINER_COLOR); if (val != null) { try { return val.getBoolean(); } catch (AttributeException e) { // } } return false; }
java
{ "resource": "" }
q14701
MapElement.getVisualizationType
train
@Pure public VisualizationType getVisualizationType() { if (this.vizualizationType == null) { final AttributeValue val = getAttributeCollection().getAttribute(ATTR_VISUALIZATION_TYPE); if (val != null) { try { this.vizualizationType = val.getJavaObject(); } catch (Exception e) { // } } if (this.vizualizationType == null) { this.vizualizationType = VisualizationType.SHAPE_ONLY; } } return this.vizualizationType; }
java
{ "resource": "" }
q14702
MapElement.setVisualizationType
train
public void setVisualizationType(VisualizationType type) { try { if (getVisualizationType() != type) { this.vizualizationType = type; getAttributeCollection().setAttribute(ATTR_VISUALIZATION_TYPE, new AttributeValueImpl(type)); } } catch (AttributeException e) { // } }
java
{ "resource": "" }
q14703
GeomFactory1dfx.newVector
train
@SuppressWarnings("static-method") public Vector1dfx newVector(ObjectProperty<WeakReference<Segment1D<?, ?>>> segment, DoubleProperty x, DoubleProperty y) { return new Vector1dfx(segment, x, y); }
java
{ "resource": "" }
q14704
HSUtils.isBlank
train
public static final boolean isBlank(String s) { if (s == null || s.trim().length() == 0) { return true; } return false; }
java
{ "resource": "" }
q14705
OutputParameter.set
train
public T set(T newValue) { final T obj = this.object; this.object = newValue; return obj; }
java
{ "resource": "" }
q14706
RoadNetworkConstants.getPreferredAttributeNameForRoadWidth
train
@Pure public static String getPreferredAttributeNameForRoadWidth() { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { return prefs.get("ROAD_WIDTH_ATTR_NAME", DEFAULT_ATTR_ROAD_WIDTH); //$NON-NLS-1$ } return DEFAULT_ATTR_ROAD_WIDTH; }
java
{ "resource": "" }
q14707
RoadNetworkConstants.setPreferredAttributeNameForRoadWidth
train
public static void setPreferredAttributeNameForRoadWidth(String name) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { if (name == null || "".equals(name) || DEFAULT_ATTR_ROAD_WIDTH.equalsIgnoreCase(name)) { //$NON-NLS-1$ prefs.remove("ROAD_WIDTH_ATTR_NAME"); //$NON-NLS-1$ } else { prefs.put("ROAD_WIDTH_ATTR_NAME", name); //$NON-NLS-1$ } } }
java
{ "resource": "" }
q14708
RoadNetworkConstants.getPreferredAttributeNameForLaneCount
train
@Pure public static String getPreferredAttributeNameForLaneCount() { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { return prefs.get("LANE_COUNT_ATTR_NAME", DEFAULT_ATTR_LANE_COUNT); //$NON-NLS-1$ } return DEFAULT_ATTR_LANE_COUNT; }
java
{ "resource": "" }
q14709
RoadNetworkConstants.setPreferredAttributeNameForLaneCount
train
public static void setPreferredAttributeNameForLaneCount(String name) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { if (name == null || "".equals(name) || DEFAULT_ATTR_LANE_COUNT.equalsIgnoreCase(name)) { //$NON-NLS-1$ prefs.remove("LANE_COUNT_ATTR_NAME"); //$NON-NLS-1$ } else { prefs.put("LANE_COUNT_ATTR_NAME", name); //$NON-NLS-1$ } } }
java
{ "resource": "" }
q14710
RoadNetworkConstants.getPreferredLaneCount
train
@Pure public static int getPreferredLaneCount() { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { return prefs.getInt("LANE_COUNT", DEFAULT_LANE_COUNT); //$NON-NLS-1$ } return DEFAULT_LANE_COUNT; }
java
{ "resource": "" }
q14711
RoadNetworkConstants.setPreferredLaneCount
train
public static void setPreferredLaneCount(int count) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { if (count < 0) { prefs.remove("LANE_COUNT"); //$NON-NLS-1$ } else { prefs.putInt("LANE_COUNT", count); //$NON-NLS-1$ } } }
java
{ "resource": "" }
q14712
RoadNetworkConstants.getPreferredLaneWidth
train
@Pure public static double getPreferredLaneWidth() { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { return prefs.getDouble("LANE_WIDTH", DEFAULT_LANE_WIDTH); //$NON-NLS-1$ } return DEFAULT_LANE_WIDTH; }
java
{ "resource": "" }
q14713
RoadNetworkConstants.setPreferredLaneWidth
train
public static void setPreferredLaneWidth(double width) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { if (width <= 0) { prefs.remove("LANE_WIDTH"); //$NON-NLS-1$ } else { prefs.putDouble("LANE_WIDTH", width); //$NON-NLS-1$ } } }
java
{ "resource": "" }
q14714
RoadNetworkConstants.getPreferredLegalTrafficSide
train
@Pure public static LegalTrafficSide getPreferredLegalTrafficSide() { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); String name = null; if (prefs != null) { name = prefs.get("LEGAL_TRAFFIC_SIDE", null); //$NON-NLS-1$ } if (name != null) { LegalTrafficSide side; try { side = LegalTrafficSide.valueOf(name); } catch (Throwable exception) { side = null; } if (side != null) { return side; } } return LegalTrafficSide.getCurrent(); }
java
{ "resource": "" }
q14715
RoadNetworkConstants.setPreferredLegalTrafficSide
train
public static void setPreferredLegalTrafficSide(LegalTrafficSide side) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { if (side == null) { prefs.remove("LEGAL_TRAFFIC_SIDE"); //$NON-NLS-1$ } else { prefs.put("LEGAL_TRAFFIC_SIDE", side.name()); //$NON-NLS-1$ } } }
java
{ "resource": "" }
q14716
RoadNetworkConstants.getPreferredAttributeNameForTrafficDirection
train
@Pure public static String getPreferredAttributeNameForTrafficDirection() { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { return prefs.get("TRAFFIC_DIRECTION_ATTR_NAME", DEFAULT_ATTR_TRAFFIC_DIRECTION); //$NON-NLS-1$ } return DEFAULT_ATTR_TRAFFIC_DIRECTION; }
java
{ "resource": "" }
q14717
RoadNetworkConstants.setPreferredAttributeNameForTrafficDirection
train
public static void setPreferredAttributeNameForTrafficDirection(String name) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { if (name == null || "".equals(name) || DEFAULT_ATTR_TRAFFIC_DIRECTION.equalsIgnoreCase(name)) { //$NON-NLS-1$ prefs.remove("TRAFFIC_DIRECTION_ATTR_NAME"); //$NON-NLS-1$ } else { prefs.put("TRAFFIC_DIRECTION_ATTR_NAME", name); //$NON-NLS-1$ } } }
java
{ "resource": "" }
q14718
RoadNetworkConstants.getPreferredAttributeValueForTrafficDirection
train
@Pure public static String getPreferredAttributeValueForTrafficDirection(TrafficDirection direction, int index) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { final StringBuilder b = new StringBuilder(); b.append("TRAFFIC_DIRECTION_VALUE_"); //$NON-NLS-1$ b.append(direction.name()); b.append("_"); //$NON-NLS-1$ b.append(index); final String v = prefs.get(b.toString(), null); if (v != null && !"".equals(v)) { //$NON-NLS-1$ return v; } } try { return getSystemDefault(direction, index); } catch (AssertionError e) { throw e; } catch (Throwable exception) { return null; } }
java
{ "resource": "" }
q14719
RoadNetworkConstants.getPreferredAttributeValuesForTrafficDirection
train
@Pure public static List<String> getPreferredAttributeValuesForTrafficDirection(TrafficDirection direction) { final List<String> array = new ArrayList<>(); int i = 0; String value = getPreferredAttributeValueForTrafficDirection(direction, i); while (value != null) { array.add(value); value = getPreferredAttributeValueForTrafficDirection(direction, ++i); } return array; }
java
{ "resource": "" }
q14720
RoadNetworkConstants.getSystemDefault
train
@Pure public static String getSystemDefault(TrafficDirection direction, int valueIndex) { // Values from the IGN-BDCarto standard switch (direction) { case DOUBLE_WAY: switch (valueIndex) { case 0: return DEFAULT_DOUBLE_WAY_TRAFFIC_DIRECTION_0; case 1: return DEFAULT_DOUBLE_WAY_TRAFFIC_DIRECTION_1; default: throw new IndexOutOfBoundsException(); } case NO_ENTRY: switch (valueIndex) { case 0: return DEFAULT_NO_ENTRY_TRAFFIC_DIRECTION_0; case 1: return DEFAULT_NO_ENTRY_TRAFFIC_DIRECTION_1; default: throw new IndexOutOfBoundsException(); } case NO_WAY: switch (valueIndex) { case 0: return DEFAULT_NO_WAY_TRAFFIC_DIRECTION_0; case 1: return DEFAULT_NO_WAY_TRAFFIC_DIRECTION_1; default: throw new IndexOutOfBoundsException(); } case ONE_WAY: switch (valueIndex) { case 0: return DEFAULT_ONE_WAY_TRAFFIC_DIRECTION_0; case 1: return DEFAULT_ONE_WAY_TRAFFIC_DIRECTION_1; default: throw new IndexOutOfBoundsException(); } default: } throw new IllegalArgumentException(); }
java
{ "resource": "" }
q14721
RoadNetworkConstants.getSystemDefault
train
@Pure public static String getSystemDefault(RoadType type) { switch (type) { case OTHER: return DEFAULT_OTHER_ROAD_TYPE; case PRIVACY_PATH: return DEFAULT_PRIVACY_ROAD_TYPE; case TRACK: return DEFAULT_TRACK_ROAD_TYPE; case BIKEWAY: return DEFAULT_BIKEWAY_ROAD_TYPE; case LOCAL_ROAD: return DEFAULT_LOCAL_ROAD_ROAD_TYPE; case INTERCHANGE_RAMP: return DEFAULT_INTERCHANGE_RAMP_ROAD_TYPE; case MAJOR_URBAN_AXIS: return DEFAULT_MAJOR_URBAN_ROAD_TYPE; case SECONDARY_ROAD: return DEFAULT_SECONDARY_ROAD_TYPE; case MAJOR_ROAD: return DEFAULT_MAJOR_ROAD_TYPE; case FREEWAY: return DEFAULT_FREEWAY_ROAD_TYPE; default: } throw new IllegalArgumentException(); }
java
{ "resource": "" }
q14722
RoadNetworkConstants.getSystemDefaults
train
@Pure public static List<String> getSystemDefaults(TrafficDirection direction) { final List<String> array = new ArrayList<>(); try { int i = 0; while (true) { array.add(getSystemDefault(direction, i)); ++i; } } catch (AssertionError e) { throw e; } catch (Throwable exception) { // } return array; }
java
{ "resource": "" }
q14723
RoadNetworkConstants.setPreferredAttributeValueForTrafficDirection
train
public static void setPreferredAttributeValueForTrafficDirection(TrafficDirection direction, int index, String value) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { final StringBuilder keyName = new StringBuilder(); keyName.append("TRAFFIC_DIRECTION_VALUE_"); //$NON-NLS-1$ keyName.append(direction.name()); keyName.append("_"); //$NON-NLS-1$ keyName.append(index); String sysDef; try { sysDef = getSystemDefault(direction, index); } catch (IndexOutOfBoundsException exception) { sysDef = null; } if (value == null || "".equals(value) //$NON-NLS-1$ || (sysDef != null && sysDef.equalsIgnoreCase(value))) { prefs.remove(keyName.toString()); return; } prefs.put(keyName.toString(), value); } }
java
{ "resource": "" }
q14724
RoadNetworkConstants.getPreferredRoadConnectionDistance
train
@Pure public static double getPreferredRoadConnectionDistance() { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { return prefs.getDouble("ROAD_CONNECTION_DISTANCE", DEFAULT_ROAD_CONNECTION_DISTANCE); //$NON-NLS-1$ } return DEFAULT_ROAD_CONNECTION_DISTANCE; }
java
{ "resource": "" }
q14725
RoadNetworkConstants.setPreferredRoadConnectionDistance
train
public static void setPreferredRoadConnectionDistance(double distance) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { if (distance <= 0.) { prefs.remove("ROAD_CONNECTION_DISTANCE"); //$NON-NLS-1$ } else { prefs.putDouble("ROAD_CONNECTION_DISTANCE", distance); //$NON-NLS-1$ } } }
java
{ "resource": "" }
q14726
RoadNetworkConstants.getPreferredRoadType
train
@Pure public static RoadType getPreferredRoadType() { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); String name = null; if (prefs != null) { name = prefs.get("ROAD_TYPE", null); //$NON-NLS-1$ } if (name != null) { RoadType type; try { type = RoadType.valueOf(name); } catch (Throwable exception) { type = null; } if (type != null) { return type; } } return RoadType.OTHER; }
java
{ "resource": "" }
q14727
RoadNetworkConstants.setPreferredRoadType
train
public static void setPreferredRoadType(RoadType type) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { if (type == null) { prefs.remove("ROAD_TYPE"); //$NON-NLS-1$ } else { prefs.put("ROAD_TYPE", type.name()); //$NON-NLS-1$ } } }
java
{ "resource": "" }
q14728
RoadNetworkConstants.getPreferredAttributeNameForRoadType
train
@Pure public static String getPreferredAttributeNameForRoadType() { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { return prefs.get("ROAD_TYPE_ATTR_NAME", DEFAULT_ATTR_ROAD_TYPE); //$NON-NLS-1$ } return DEFAULT_ATTR_ROAD_TYPE; }
java
{ "resource": "" }
q14729
RoadNetworkConstants.setPreferredAttributeNameForRoadType
train
public static void setPreferredAttributeNameForRoadType(String name) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { if (name == null || "".equals(name) || DEFAULT_ATTR_ROAD_TYPE.equalsIgnoreCase(name)) { //$NON-NLS-1$ prefs.remove("ROAD_TYPE_ATTR_NAME"); //$NON-NLS-1$ } else { prefs.put("ROAD_TYPE_ATTR_NAME", name); //$NON-NLS-1$ } } }
java
{ "resource": "" }
q14730
RoadNetworkConstants.getPreferredAttributeValueForRoadType
train
@Pure public static String getPreferredAttributeValueForRoadType(RoadType type) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { final String v = prefs.get("ROAD_TYPE_VALUE_" + type.name(), null); //$NON-NLS-1$ if (v != null && !"".equals(v)) { //$NON-NLS-1$ return v; } } return getSystemDefault(type); }
java
{ "resource": "" }
q14731
RoadNetworkConstants.setPreferredAttributeValueForRoadType
train
public static void setPreferredAttributeValueForRoadType(RoadType type, String value) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { final String sysDef = getSystemDefault(type); if (value == null || "".equals(value) || sysDef.equalsIgnoreCase(value)) { //$NON-NLS-1$ prefs.remove("ROAD_TYPE_VALUE_" + type.name()); //$NON-NLS-1$ } else { prefs.put("ROAD_TYPE_VALUE_" + type.name(), value); //$NON-NLS-1$ } } }
java
{ "resource": "" }
q14732
RoadNetworkConstants.getPreferredAttributeNameForRoadName
train
@Pure public static String getPreferredAttributeNameForRoadName() { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { return prefs.get("ROAD_NAME_ATTR_NAME", DEFAULT_ATTR_ROAD_NAME); //$NON-NLS-1$ } return DEFAULT_ATTR_ROAD_NAME; }
java
{ "resource": "" }
q14733
RoadNetworkConstants.setPreferredAttributeNameForRoadName
train
public static void setPreferredAttributeNameForRoadName(String name) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { if (name == null || "".equals(name) || DEFAULT_ATTR_ROAD_NAME.equalsIgnoreCase(name)) { //$NON-NLS-1$ prefs.remove("ROAD_NAME_ATTR_NAME"); //$NON-NLS-1$ } else { prefs.put("ROAD_NAME_ATTR_NAME", name); //$NON-NLS-1$ } } }
java
{ "resource": "" }
q14734
RoadNetworkConstants.getPreferredAttributeNameForRoadNumber
train
@Pure public static String getPreferredAttributeNameForRoadNumber() { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { return prefs.get("ROAD_NUMBER_ATTR_NAME", DEFAULT_ATTR_ROAD_NUMBER); //$NON-NLS-1$ } return DEFAULT_ATTR_ROAD_NUMBER; }
java
{ "resource": "" }
q14735
RoadNetworkConstants.setPreferredAttributeNameForRoadNumber
train
public static void setPreferredAttributeNameForRoadNumber(String name) { final Preferences prefs = Preferences.userNodeForPackage(RoadNetworkConstants.class); if (prefs != null) { if (name == null || "".equals(name) || DEFAULT_ATTR_ROAD_NUMBER.equalsIgnoreCase(name)) { //$NON-NLS-1$ prefs.remove("ROAD_NUMBER_ATTR_NAME"); //$NON-NLS-1$ } else { prefs.put("ROAD_NUMBER_ATTR_NAME", name); //$NON-NLS-1$ } } }
java
{ "resource": "" }
q14736
DBaseFileReader.readDBFHeader
train
@SuppressWarnings("checkstyle:magicnumber") public void readDBFHeader() throws IOException { if (this.finished) { throw new EOFDBaseFileException(); } if (this.fieldCount != -1) { // The header was already red return; } //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 0 1 byte DBF Format id // 0x03: FoxBase+, FoxPro, dBASEIII+ // dBASEIV, no memo // 0x83: FoxBase+, dBASEIII+ with memo // 0xF5: FoxPro with memo // 0x8B: dBASEIV with memo // 0x8E: dBASEIV with SQL table this.fileVersion = this.stream.readByte(); //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 1-3 3 bytes Date of last update: YMD final Calendar cal = new GregorianCalendar(); cal.set(Calendar.YEAR, this.stream.readByte() + 1900); cal.set(Calendar.MONTH, this.stream.readByte() - 1); cal.set(Calendar.DAY_OF_MONTH, this.stream.readByte()); this.lastUpdateDate = cal.getTime(); // Get the count of records // //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 4-7 4 bytes Number of records in the table this.recordCount = this.stream.readLEInt(); // Get the count of fields (nbBytes / size of a Field - ending byte ODh) // //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 8-9 2 bytes Number of bytes in the header // #bytes = 32 + 32 * #fields + 1; this.fieldCount = (this.stream.readLEShort() - 1) / 32 - 1; // Skip the ending chars of the header // //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 10-11 2 bytes Number of bytes in the record this.recordSize = this.stream.readLEShort(); //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 12-13 2 bytes Reserved // 14 1 byte Incomplete transaction // 0x00: Ignored / Transaction End // 0x01: Transaction started // 15 1 byte Encryption flag // 0x00: Not encrypted // 0x01: Encrypted // 16-19 4 bytes Free record thread (reserved for LAN only) // 20-27 8 bytes Reserved for multi-user dBASE (dBASE III+) // 28 1 byte MDX flag (dBASE IV) // 0x00: index upon demand // 0x01: production index exists this.stream.skipBytes(17); // use skipBytes because it force to skip the specified amount, instead of skip() //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 29 1 byte Language driver ID // See {@link DBaseCodePage} for details. final byte b = this.stream.readByte(); this.codePage = DBaseCodePage.fromLanguageCode(b); //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 30-31 2 bytes Reserved this.stream.skipBytes(2); // use skipBytes because it force to skip the specified amount, instead of skip() // Update the offset of the first record with the size of the header this.firstRecordOffset = 32; }
java
{ "resource": "" }
q14737
DBaseFileReader.getDBFFieldName
train
@Pure public String getDBFFieldName(int index) { if (this.fieldCount != -1) { try { final DBaseFileField field = this.fields.get(index); if (field != null) { return field.getName(); } } catch (Exception exception) { // } } return null; }
java
{ "resource": "" }
q14738
DBaseFileReader.getDBFFieldIndex
train
@Pure public int getDBFFieldIndex(String name) { assert name != null; if (this.fieldCount != -1) { try { int i = 0; for (final DBaseFileField field : this.fields) { if (field != null && name.equals(field.getName())) { return i; } ++i; } } catch (Exception exception) { // } } return -1; }
java
{ "resource": "" }
q14739
DBaseFileReader.getDBFFieldType
train
@Pure public DBaseFieldType getDBFFieldType(int index) { if (this.fieldCount != -1) { try { final DBaseFileField field = this.fields.get(index); if (field != null) { return field.getType(); } } catch (Exception exception) { // } } return null; }
java
{ "resource": "" }
q14740
DBaseFileReader.readDBFFields
train
@SuppressWarnings({"checkstyle:npathcomplexity", "checkstyle:magicnumber"}) public List<DBaseFileField> readDBFFields() throws IOException, EOFException { if (this.fields != null) { return this.fields; } if (this.finished) { throw new EOFDBaseFileException(); } if (this.fieldCount == -1) { throw new MustCallReadHeaderFunctionException(); } // //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 32-m n*32 bytes Field descriptors (see bellow) // m+1 1 byte terminator character 0x0D // A field contains at least the "removal flag" byte int byteSize = 1; final ArrayList<DBaseFileField> array = new ArrayList<>(); final Charset charSet = (this.codePage == null) ? null : this.codePage.getChatset(); String columnName; for (int idxFields = 0; idxFields < this.fieldCount; ++idxFields) { // Read the field header // //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 0-10 11 bytes Field name, filled with 0x00 // 11 1 byte Field type (see bellow) // 12-15 4 bytes Field data address, not useful for disk // 16 1 byte Field length // 17 1 byte Field decimal count // 18-19 2 bytes Reserved for dBASE III+ on a Lan // 20 1 byte Work area ID // 21-22 2 bytes Reserved for dBASE III+ on a Lan // 23 1 byte SET FIELDS flag // 24-31 7 bytes Reserved final byte[] header = new byte[32]; this.stream.readFully(header); // Update the offset of the first record with the end-of-header character this.firstRecordOffset += header.length; // Read the name of the field until 0x00 int nbChars = 0; for (int i = 0; i <= 10; ++i) { if (header[i] == 0) { break; } ++nbChars; } final byte[] bName = new byte[nbChars]; System.arraycopy(header, 0, bName, 0, nbChars); if (charSet != null) { columnName = new String(bName, charSet); } else { columnName = new String(bName); } // Read the type final DBaseFieldType dbftype = DBaseFieldType.fromByte(header[11]); final DBaseFileField field = new DBaseFileField( columnName, dbftype, // convert unsigned byte into int header[16] & 0xFF, // convert unsigned byte into int header[17] & 0xFF, idxFields); array.add(field); byteSize += field.getLength(); } // Check if the byte size of the field list corresponds to size specified record size inside the header if (byteSize != this.recordSize) { throw new InvalidRecordSizeException(this.recordSize, byteSize); } // Read the terminator character 0x0D final byte bt = this.stream.readByte(); if (bt != 0x0D) { throw new InvalidDBaseFieldTerminationException(bt); } // Update the offset of the first record with the end-of-header character ++this.firstRecordOffset; this.fields = array; // Save the position inside the input stream for seeking function if (this.stream.markSupported()) { this.stream.mark(this.recordSize * this.recordCount + this.firstRecordOffset + 1); } return array; }
java
{ "resource": "" }
q14741
DBaseFileReader.skip
train
public void skip(int skipAmount) throws IOException { if (this.recordCount == -1) { throw new MustCallReadHeaderFunctionException(); } if ((this.readingPosition + skipAmount) >= this.recordCount) { throw new EOFException(); } if (skipAmount > 0) { this.readingPosition += skipAmount; //this.stream.reset(); //this.stream.skipBytes(this.recordSize * this.readingPosition); final long skippedAmount = this.stream.skipBytes(this.recordSize * skipAmount); // use skipBytes because it force to skip the specified amount, instead of skip() assert skippedAmount == this.recordSize * skipAmount; } }
java
{ "resource": "" }
q14742
DBaseFileReader.readRestOfDBFRecords
train
public List<DBaseFileRecord> readRestOfDBFRecords() throws IOException { if (this.finished) { throw new EOFDBaseFileException(); } if (this.recordCount == -1) { throw new MustCallReadHeaderFunctionException(); } final Vector<DBaseFileRecord> records = new Vector<>(); try { while (this.readingPosition < this.recordCount) { final DBaseFileRecord record = readNextDBFRecord(); if (record != null) { records.add(record); } } } catch (EOFException e) { // } this.finished = true; this.stream.close(); return records; }
java
{ "resource": "" }
q14743
DBaseFileReader.readStringRecordValue
train
private int readStringRecordValue(DBaseFileField field, int nrecord, int nfield, byte[] rawData, int rawOffset, OutputParameter<String> value) throws IOException { final byte[] recordData = new byte[field.getLength()]; System.arraycopy(rawData, rawOffset, recordData, 0, recordData.length); String data; if (hasOption(OPTION_DECODE_STRING)) { data = Locale.decodeString(recordData).trim(); } else { data = new String(recordData).trim(); } // ignore the data that does not contain anything if (data == null || data.length() == 0 || DBaseFileField.isUnsetValue(data)) { data = null; } value.set(data); return recordData.length; }
java
{ "resource": "" }
q14744
DBaseFileReader.readDateRecordValue
train
@SuppressWarnings("checkstyle:magicnumber") private static int readDateRecordValue(DBaseFileField field, int nrecord, int nfield, byte[] rawData, int rawOffset, OutputParameter<Date> value) throws IOException { final GregorianCalendar cal = new GregorianCalendar(); final int year = ((rawData[rawOffset] & 0xFF) - '0') * 1000 + ((rawData[rawOffset + 1] & 0xFF) - '0') * 100 + ((rawData[rawOffset + 2] & 0xFF) - '0') * 10 + ((rawData[rawOffset + 3] & 0xFF) - '0'); final int month = ((rawData[rawOffset + 4] & 0xFF) - '0') * 10 + ((rawData[rawOffset + 5] & 0xFF) - '0'); final int day = ((rawData[rawOffset + 6] & 0xFF) - '0') * 10 + ((rawData[rawOffset + 7] & 0xFF) - '0'); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); cal.set(Calendar.DAY_OF_MONTH, day); if (year == cal.get(Calendar.YEAR) && month == cal.get(Calendar.MONTH) && day == cal.get(Calendar.DAY_OF_MONTH)) { value.set(cal.getTime()); return 8; } throw new InvalidRawDataFormatException(nrecord, nfield, new String(rawData, rawOffset, field.getLength())); }
java
{ "resource": "" }
q14745
DBaseFileReader.readNumberRecordValue
train
private static int readNumberRecordValue(DBaseFileField field, int nrecord, int nfield, byte[] rawData, int rawOffset, OutputParameter<Double> value) throws IOException { final String buffer = new String(rawData, rawOffset, field.getLength()); try { final String b = buffer.trim(); if (b != null && b.length() > 0) { value.set(new Double(b)); return field.getLength(); } } catch (NumberFormatException e) { // } throw new InvalidRawDataFormatException(nrecord, nfield, buffer); }
java
{ "resource": "" }
q14746
DBaseFileReader.readBooleanRecordValue
train
@SuppressWarnings("checkstyle:magicnumber") private static int readBooleanRecordValue(DBaseFileField field, int nrecord, int nfield, byte[] rawData, int rawOffset, OutputParameter<Boolean> value) throws IOException { final int byteCode = rawData[rawOffset] & 0xFF; if (TRUE_CHARS.indexOf(byteCode) != -1) { value.set(true); return 1; } if (FALSE_CHARS.indexOf(byteCode) != -1) { value.set(false); return 1; } throw new InvalidRawDataFormatException(nrecord, nfield, Integer.toString(byteCode)); }
java
{ "resource": "" }
q14747
DBaseFileReader.read2ByteIntegerRecordValue
train
private static int read2ByteIntegerRecordValue(DBaseFileField field, int nrecord, int nfield, byte[] rawData, int rawOffset, OutputParameter<Integer> value) throws IOException { final short rawNumber = EndianNumbers.toLEShort(rawData[rawOffset], rawData[rawOffset + 1]); try { value.set(new Integer(rawNumber)); return 2; } catch (NumberFormatException exception) { throw new InvalidRawDataFormatException(nrecord, nfield, Short.toString(rawNumber)); } }
java
{ "resource": "" }
q14748
DBaseFileReader.read4ByteIntegerRecordValue
train
@SuppressWarnings("checkstyle:magicnumber") private static int read4ByteIntegerRecordValue(DBaseFileField field, int nrecord, int nfield, byte[] rawData, int rawOffset, OutputParameter<Long> value) throws IOException { final int rawNumber = EndianNumbers.toLEInt( rawData[rawOffset], rawData[rawOffset + 1], rawData[rawOffset + 2], rawData[rawOffset + 3]); try { value.set(new Long(rawNumber)); return 4; } catch (NumberFormatException exception) { throw new InvalidRawDataFormatException(nrecord, nfield, Long.toString(rawNumber)); } }
java
{ "resource": "" }
q14749
DBaseFileReader.read8ByteDoubleRecordValue
train
@SuppressWarnings("checkstyle:magicnumber") private static int read8ByteDoubleRecordValue(DBaseFileField field, int nrecord, int nfield, byte[] rawData, int rawOffset, OutputParameter<Double> value) throws IOException { final double rawNumber = EndianNumbers.toLEDouble( rawData[rawOffset], rawData[rawOffset + 1], rawData[rawOffset + 2], rawData[rawOffset + 3], rawData[rawOffset + 4], rawData[rawOffset + 5], rawData[rawOffset + 6], rawData[rawOffset + 7]); try { value.set(new Double(rawNumber)); return 8; } catch (NumberFormatException exception) { throw new InvalidRawDataFormatException(nrecord, nfield, Double.toString(rawNumber)); } }
java
{ "resource": "" }
q14750
DBaseFileReader.isColumnSelectable
train
@Pure public boolean isColumnSelectable(DBaseFileField column) { return column != null && (this.selectedColumns.isEmpty() || this.selectedColumns.contains(column)); }
java
{ "resource": "" }
q14751
Encryption.loadDefaultEncryptionModule
train
public static void loadDefaultEncryptionModule() { // Be sure that the cryptographical algorithms are loaded final Provider[] providers = Security.getProviders(); boolean found = false; for (final Provider provider : providers) { if (provider instanceof SunJCE) { found = true; break; } } if (!found) { Security.addProvider(new SunJCE()); } }
java
{ "resource": "" }
q14752
Encryption.md5
train
public static String md5(String str) { if (str == null) { return ""; //$NON-NLS-1$ } final byte[] uniqueKey = str.getBytes(); byte[] hash = null; try { hash = MessageDigest.getInstance("MD5").digest(uniqueKey); //$NON-NLS-1$ } catch (NoSuchAlgorithmException e) { throw new Error(Locale.getString("NO_MD5")); //$NON-NLS-1$ } final StringBuilder hashString = new StringBuilder(); for (int i = 0; i < hash.length; ++i) { final String hex = Integer.toHexString(hash[i]); if (hex.length() == 1) { hashString.append('0'); hashString.append(hex.charAt(hex.length() - 1)); } else { hashString.append(hex.substring(hex.length() - 2)); } } return hashString.toString(); }
java
{ "resource": "" }
q14753
Path3ifx.isMultiPartsProperty
train
public BooleanProperty isMultiPartsProperty() { if (this.isMultipart == null) { this.isMultipart = new ReadOnlyBooleanWrapper(this, MathFXAttributeNames.IS_MULTIPARTS, false); this.isMultipart.bind(Bindings.createBooleanBinding(() -> { boolean foundOne = false; for (final PathElementType type : innerTypesProperty()) { if (type == PathElementType.MOVE_TO) { if (foundOne) { return true; } foundOne = true; } } return false; }, innerTypesProperty())); } return this.isMultipart; }
java
{ "resource": "" }
q14754
DssatWthFileHelper.getWthInsiCodeOr
train
private String getWthInsiCodeOr(Map wthData) { String insiName = getWthInsiCode(wthData); if (insiName.equals("")) { return getNextDefName(); } else { return insiName; } }
java
{ "resource": "" }
q14755
DssatWthFileHelper.getWthInsiCode
train
public static String getWthInsiCode(Map wthData) { String wst_name = getValueOr(wthData, "wst_name", ""); if (wst_name.matches("(\\w{4})|(\\w{8})")) { return wst_name; } String wst_id = getValueOr(wthData, "wst_id", ""); if (wst_id.matches("(\\w{4})|(\\w{8})")) { return wst_id; } wst_id = getValueOr(wthData, "dssat_insi", ""); if (wst_id.matches("(\\w{4})|(\\w{8})")) { return wst_id; } return ""; }
java
{ "resource": "" }
q14756
DssatWthFileHelper.getWthYearDuration
train
public static String getWthYearDuration(Map wthData) { String yearDur = ""; ArrayList<Map> wthRecords = (ArrayList) getObjectOr(wthData, "dailyWeather", new ArrayList()); if (!wthRecords.isEmpty()) { // Get the year of starting date and end date String startYear = getValueOr((wthRecords.get(0)), "w_date", " ").substring(2, 4).trim(); String endYear = getValueOr((wthRecords.get(wthRecords.size() - 1)), "w_date", " ").substring(2, 4).trim(); // If not available, do not show year and duration in the file name if (!startYear.equals("") && !endYear.equals("")) { yearDur += startYear; try { int iStartYear = Integer.parseInt(startYear); int iEndYear = Integer.parseInt(endYear); iStartYear += iStartYear <= 15 ? 2000 : 1900; // P.S. 2015 is the cross year for the current version iEndYear += iEndYear <= 15 ? 2000 : 1900; // P.S. 2015 is the cross year for the current version int duration = iEndYear - iStartYear + 1; // P.S. Currently the system only support the maximum of 99 years for duration duration = duration > 99 ? 99 : duration; yearDur += String.format("%02d", duration); } catch (Exception e) { yearDur += "01"; // Default duration uses 01 (minimum value) } } } return yearDur; }
java
{ "resource": "" }
q14757
IndexBuilder.setupIndexer
train
private static IndexEnvironment setupIndexer(File outputDirectory, int memory, boolean storeDocs) throws Exception { final IndexEnvironment env = new IndexEnvironment(); env.setMemory(memory * ONE_MEGABYTE); final Specification spec = env.getFileClassSpec("trectext"); env.addFileClass(spec); env.setStoreDocs(storeDocs); // if we don't build indices on DOCNO then getting the docIds at query time is // extremely slow env.setMetadataIndexedFields(new String[]{"docno"}, new String[]{"docno"}); env.create(outputDirectory.getAbsolutePath(), statusMonitor); return env; }
java
{ "resource": "" }
q14758
InspectorTreeNode.registerConsumer
train
@SuppressWarnings("unchecked") void registerConsumer(Inspector<? super OutT> subInspector) { consumers.add((Inspector<OutT>) subInspector); }
java
{ "resource": "" }
q14759
GISTreeSetUtil.classifies
train
@Pure public static int classifies(AbstractGISTreeSetNode<?, ?> node, GeoLocation location) { if (node.getZone() == IcosepQuadTreeZone.ICOSEP) { return classifiesIcocep(node.verticalSplit, node.horizontalSplit, location.toBounds2D()); } return classifiesNonIcocep(node.verticalSplit, node.horizontalSplit, location.toBounds2D()); }
java
{ "resource": "" }
q14760
GISTreeSetUtil.contains
train
@Pure static boolean contains(int region, double cutX, double cutY, double pointX, double pointY) { switch (IcosepQuadTreeZone.values()[region]) { case SOUTH_WEST: return pointX <= cutX && pointY <= cutY; case SOUTH_EAST: return pointX >= cutX && pointY <= cutY; case NORTH_WEST: return pointX <= cutX && pointY >= cutY; case NORTH_EAST: return pointX >= cutX && pointY >= cutY; case ICOSEP: return true; default: } return false; }
java
{ "resource": "" }
q14761
GISTreeSetUtil.isOutsideNodeBuildingBounds
train
@Pure private static boolean isOutsideNodeBuildingBounds(AbstractGISTreeSetNode<?, ?> node, Rectangle2afp<?, ?, ?, ?, ?, ?> location) { final Rectangle2d b2 = getNormalizedNodeBuildingBounds(node, location); if (b2 == null) { return false; } return Rectangle2afp.classifiesRectangleRectangle( b2.getMinX(), b2.getMinY(), b2.getMaxX(), b2.getMaxY(), location.getMinX(), location.getMinY(), location.getMaxX(), location.getMaxY()) != IntersectionType.INSIDE; }
java
{ "resource": "" }
q14762
GISTreeSetUtil.union
train
private static Rectangle2d union(AbstractGISTreeSetNode<?, ?> node, Rectangle2afp<?, ?, ?, ?, ?, ?> shape) { final Rectangle2d b = getNodeBuildingBounds(node); b.setUnion(shape); normalize(b, shape); return b; }
java
{ "resource": "" }
q14763
GISTreeSetUtil.getNodeBuildingBounds
train
@Pure public static Rectangle2d getNodeBuildingBounds(AbstractGISTreeSetNode<?, ?> node) { assert node != null; final double w = node.nodeWidth / 2.; final double h = node.nodeHeight / 2.; final IcosepQuadTreeZone zone = node.getZone(); final double lx; final double ly; if (zone == null) { // Is root node lx = node.verticalSplit - w; ly = node.horizontalSplit - h; } else { switch (zone) { case SOUTH_EAST: lx = node.verticalSplit; ly = node.horizontalSplit - h; break; case SOUTH_WEST: lx = node.verticalSplit - w; ly = node.horizontalSplit - h; break; case NORTH_EAST: lx = node.verticalSplit; ly = node.horizontalSplit; break; case NORTH_WEST: lx = node.verticalSplit - w; ly = node.horizontalSplit; break; case ICOSEP: return getNodeBuildingBounds(node.getParentNode()); default: throw new IllegalStateException(); } } return new Rectangle2d(lx, ly, node.nodeWidth, node.nodeHeight); }
java
{ "resource": "" }
q14764
GISTreeSetUtil.createNode
train
private static <P extends GISPrimitive, N extends AbstractGISTreeSetNode<P, N>> N createNode(N parent, IcosepQuadTreeZone region, GISTreeSetNodeFactory<P, N> builder) { Rectangle2d area = parent.getAreaBounds(); if (region == IcosepQuadTreeZone.ICOSEP) { return builder.newNode( IcosepQuadTreeZone.ICOSEP, area.getMinX(), area.getMinY(), area.getWidth(), area.getHeight()); } if (parent.getZone() == IcosepQuadTreeZone.ICOSEP) { area = computeIcosepSubarea(region, area); return builder.newNode( region, area.getMinX(), area.getMinY(), area.getWidth(), area.getHeight()); } final Point2d childCutPlane = computeCutPoint(region, parent); assert childCutPlane != null; final double w = area.getWidth() / 4.; final double h = area.getHeight() / 4.; return builder.newNode(region, childCutPlane.getX() - w, childCutPlane.getY() - h, 2. * w, 2. * h); }
java
{ "resource": "" }
q14765
GISTreeSetUtil.computeIcosepSubarea
train
private static Rectangle2d computeIcosepSubarea(IcosepQuadTreeZone region, Rectangle2d area) { if (area == null || area.isEmpty()) { return area; } final double demiWidth = area.getWidth() / 2.; final double demiHeight = area.getHeight() / 2.; switch (region) { case ICOSEP: return area; case SOUTH_WEST: return new Rectangle2d( area.getMinX(), area.getMinY(), demiWidth, demiHeight); case NORTH_WEST: return new Rectangle2d( area.getMinX(), area.getCenterY(), demiWidth, demiHeight); case NORTH_EAST: return new Rectangle2d( area.getCenterX(), area.getMinY(), demiWidth, demiHeight); case SOUTH_EAST: return new Rectangle2d( area.getMinX(), area.getMinY(), demiWidth, demiHeight); default: } throw new IllegalStateException(); }
java
{ "resource": "" }
q14766
GISTreeSetUtil.computeCutPoint
train
private static <P extends GISPrimitive, N extends AbstractGISTreeSetNode<P, N>> Point2d computeCutPoint(IcosepQuadTreeZone region, N parent) { final double w = parent.nodeWidth / 4.; final double h = parent.nodeHeight / 4.; final double x; final double y; switch (region) { case SOUTH_WEST: x = parent.verticalSplit - w; y = parent.horizontalSplit - h; break; case SOUTH_EAST: x = parent.verticalSplit + w; y = parent.horizontalSplit - h; break; case NORTH_WEST: x = parent.verticalSplit - w; y = parent.horizontalSplit + h; break; case NORTH_EAST: x = parent.verticalSplit + w; y = parent.horizontalSplit + h; break; case ICOSEP: default: return null; } return new Point2d(x, y); }
java
{ "resource": "" }
q14767
GISTreeSetUtil.rearrangeTree
train
private static <P extends GISPrimitive, N extends AbstractGISTreeSetNode<P, N>> N rearrangeTree(AbstractGISTreeSet<P, N> tree, N node, Rectangle2afp<?, ?, ?, ?, ?, ?> desiredBounds, GISTreeSetNodeFactory<P, N> builder) { // Search for the node that completely contains the desired area N topNode = node.getParentNode(); while (topNode != null && isOutsideNodeBuildingBounds(topNode, desiredBounds)) { topNode = topNode.getParentNode(); } final Rectangle2afp<?, ?, ?, ?, ?, ?> dr; if (topNode == null) { // Node node found, the entire tree should be rebuilt topNode = tree.getTree().getRoot(); if (topNode == null) { throw new IllegalStateException(); } dr = union(topNode, desiredBounds); } else { dr = getNormalizedNodeBuildingBounds(topNode, desiredBounds); } // Build a new subtree final N parent = topNode.getParentNode(); final Iterator<P> dataIterator = new PrefixDataDepthFirstTreeIterator<>(topNode); final N newTopNode = builder.newNode( topNode.getZone(), dr.getMinX(), dr.getMinY(), dr.getWidth(), dr.getHeight()); while (dataIterator.hasNext()) { if (!addInside(tree, newTopNode, dataIterator.next(), builder, false)) { throw new IllegalStateException(); } } // Replace rearranged subtree by the new one if (parent != null) { parent.setChildAt(topNode.getZone().ordinal(), newTopNode); return parent; } tree.getTree().setRoot(newTopNode); return newTopNode; }
java
{ "resource": "" }
q14768
AbstractShape3i.addShapeGeometryChangeListener
train
protected synchronized void addShapeGeometryChangeListener(ShapeGeometryChangeListener listener) { assert listener != null : AssertMessages.notNullParameter(); if (this.geometryListeners == null) { this.geometryListeners = new WeakArrayList<>(); } this.geometryListeners.add(listener); }
java
{ "resource": "" }
q14769
AbstractShape3i.removeShapeGeometryChangeListener
train
protected synchronized void removeShapeGeometryChangeListener(ShapeGeometryChangeListener listener) { assert listener != null : AssertMessages.notNullParameter(); if (this.geometryListeners != null) { this.geometryListeners.remove(listener); if (this.geometryListeners.isEmpty()) { this.geometryListeners = null; } } }
java
{ "resource": "" }
q14770
AbstractShape3i.fireGeometryChange
train
protected synchronized void fireGeometryChange() { if (this.geometryListeners == null) { return; } final ShapeGeometryChangeListener[] array = new ShapeGeometryChangeListener[this.geometryListeners.size()]; this.geometryListeners.toArray(array); for (final ShapeGeometryChangeListener listener : array) { listener.shapeGeometryChange(this); } }
java
{ "resource": "" }
q14771
ZoomablePane.setupListeners
train
protected void setupListeners() { addDrawingListener(new DrawingListener() { private long time; @Override public void onDrawingStart() { this.time = System.currentTimeMillis(); getCorner().setColor(Color.ORANGERED); } @Override public void onDrawingEnd() { getCorner().setColor(null); final long duration = System.currentTimeMillis() - this.time; getLogger().fine("Rendering duration: " + Duration.millis(duration).toString()); //$NON-NLS-1$ } }); }
java
{ "resource": "" }
q14772
ZoomablePane.setupMousing
train
@SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity", "checkstyle:nestedifdepth"}) protected void setupMousing() { final ZoomableCanvas<T> canvas = getDocumentCanvas(); canvas.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> { this.pressX = e.getX(); this.pressY = e.getY(); this.hbarValue = this.hbar.getValue(); this.vbarValue = this.vbar.getValue(); }); setOnDragDetected(getDefaultOnDragDetectedEventHandler()); addEventFilter(MouseEvent.MOUSE_RELEASED, e -> { if (this.dragDetected) { this.dragDetected = false; final Cursor scurs = this.savedCursor; this.savedCursor = null; if (scurs != null) { getDocumentCanvas().setCursor(scurs); requestLayout(); } } }); addEventHandler(DragEvent.DRAG_DONE, event -> { if (this.dragDetected) { this.dragDetected = false; final Cursor scurs = this.savedCursor; this.savedCursor = null; if (scurs != null) { getDocumentCanvas().setCursor(scurs); requestLayout(); } } }); addEventHandler(MouseEvent.MOUSE_DRAGGED, getDefaultOnMouseDraggedEventHandler()); addEventHandler(ScrollEvent.SCROLL_STARTED, event -> { this.scrollDetected = true; }); addEventHandler(ScrollEvent.SCROLL_FINISHED, event -> { this.scrollDetected = false; }); addEventHandler(ScrollEvent.SCROLL, event -> { if (!this.scrollDetected) { event.consume(); final double delta; if (event.getDeltaY() != 0.) { delta = event.getDeltaY(); } else { delta = event.getDeltaX(); } if (delta < 0) { zoomOut(); } else { zoomIn(); } } }); }
java
{ "resource": "" }
q14773
ZoomablePane.setupKeying
train
protected void setupKeying() { setOnKeyPressed(event -> { switch (event.getCode()) { case LEFT: moveLeft(event.isShiftDown(), event.isControlDown(), false); event.consume(); break; case RIGHT: moveRight(event.isShiftDown(), event.isControlDown(), false); event.consume(); break; case UP: if (event.isAltDown()) { zoomIn(); } else { moveUp(event.isShiftDown(), event.isControlDown(), false); } event.consume(); break; case DOWN: if (event.isAltDown()) { zoomOut(); } else { moveDown(event.isShiftDown(), event.isControlDown(), false); } event.consume(); break; case PAGE_UP: if (event.isControlDown()) { moveLeft(false, false, true); } else { moveUp(false, false, true); } event.consume(); break; case PAGE_DOWN: if (event.isControlDown()) { moveRight(false, false, true); } else { moveDown(false, false, true); } event.consume(); break; //$CASES-OMITTED$ default: } }); }
java
{ "resource": "" }
q14774
ZoomablePane.moveLeft
train
public void moveLeft(boolean isUnit, boolean isLarge, boolean isVeryLarge) { double inc = isUnit ? this.hbar.getUnitIncrement() : (isLarge ? LARGE_MOVE_FACTOR : (isVeryLarge ? VERY_LARGE_MOVE_FACTOR : STANDARD_MOVE_FACTOR)) * this.hbar.getBlockIncrement(); if (!isInvertedAxisX()) { inc = -inc; } this.hbar.setValue(Utils.clamp(this.hbar.getMin(), this.hbar.getValue() + inc, this.hbar.getMax())); }
java
{ "resource": "" }
q14775
ZoomablePane.moveUp
train
public void moveUp(boolean isUnit, boolean isLarge, boolean isVeryLarge) { double inc = isUnit ? this.vbar.getUnitIncrement() : (isLarge ? LARGE_MOVE_FACTOR : (isVeryLarge ? VERY_LARGE_MOVE_FACTOR : STANDARD_MOVE_FACTOR)) * this.vbar.getBlockIncrement(); if (!isInvertedAxisY()) { inc = -inc; } this.vbar.setValue(Utils.clamp(this.vbar.getMin(), this.vbar.getValue() + inc, this.vbar.getMax())); }
java
{ "resource": "" }
q14776
ZoomablePane.loggerProperty
train
public ObjectProperty<Logger> loggerProperty() { if (this.logger == null) { this.logger = new SimpleObjectProperty<Logger>(this, LOGGER_PROPERTY, Logger.getLogger(getClass().getName())) { @Override protected void invalidated() { final Logger log = get(); if (log == null) { set(Logger.getLogger(getClass().getName())); } } }; } return this.logger; }
java
{ "resource": "" }
q14777
ZoomablePane.panButtonProperty
train
public ObjectProperty<MouseButton> panButtonProperty() { if (this.panButton == null) { this.panButton = new StyleableObjectProperty<MouseButton>(DEFAULT_PAN_BUTTON) { @SuppressWarnings("synthetic-access") @Override protected void invalidated() { final MouseButton button = get(); if (button == null) { set(DEFAULT_PAN_BUTTON); } } @Override public CssMetaData<ZoomablePane<?>, MouseButton> getCssMetaData() { return StyleableProperties.PAN_BUTTON; } @Override public Object getBean() { return ZoomablePane.this; } @Override public String getName() { return PAN_BUTTON_PROPERTY; } }; } return this.panButton; }
java
{ "resource": "" }
q14778
ZoomablePane.panSensitivityProperty
train
public DoubleProperty panSensitivityProperty() { if (this.panSensitivity == null) { this.panSensitivity = new StyleableDoubleProperty(DEFAULT_PAN_SENSITIVITY) { @Override public void invalidated() { if (get() <= MIN_PAN_SENSITIVITY) { set(MIN_PAN_SENSITIVITY); } } @Override public CssMetaData<ZoomablePane<?>, Number> getCssMetaData() { return StyleableProperties.PAN_SENSITIVITY; } @Override public Object getBean() { return ZoomablePane.this; } @Override public String getName() { return PAN_SENSITIVITY_PROPERTY; } }; } return this.panSensitivity; }
java
{ "resource": "" }
q14779
ZoomablePane.getPanSensitivity
train
public double getPanSensitivity(boolean unitSensitivityModifier, boolean hugeSensivityModifier) { if (unitSensitivityModifier) { return DEFAULT_PAN_SENSITIVITY; } final double sens = getPanSensitivity(); if (hugeSensivityModifier) { return sens * LARGE_MOVE_FACTOR; } return sens; }
java
{ "resource": "" }
q14780
AbstractGeomFactoryBase.setGlobalSplineApproximationRatio
train
public static void setGlobalSplineApproximationRatio(Double distance) { if (distance == null || Double.isNaN(distance.doubleValue())) { globalSplineApproximation = GeomConstants.SPLINE_APPROXIMATION_RATIO; } else { globalSplineApproximation = Math.max(0, distance); } }
java
{ "resource": "" }
q14781
ESRIBounds.createUnion
train
public ESRIBounds createUnion(ESRIBounds bounds) { final ESRIBounds eb = new ESRIBounds(); eb.minx = (bounds.minx < this.minx) ? bounds.minx : this.minx; eb.maxx = (bounds.maxx < this.maxx) ? this.maxx : bounds.maxx; eb.miny = (bounds.miny < this.miny) ? bounds.miny : this.miny; eb.maxy = (bounds.maxy < this.maxy) ? this.maxy : bounds.maxy; eb.minz = (bounds.minz < this.minz) ? bounds.minz : this.minz; eb.maxz = (bounds.maxz < this.maxz) ? this.maxz : bounds.maxz; eb.minm = (bounds.minm < this.minm) ? bounds.minm : this.minm; eb.maxm = (bounds.maxm < this.maxm) ? this.maxm : bounds.maxm; return eb; }
java
{ "resource": "" }
q14782
ESRIBounds.add
train
public void add(ESRIPoint point) { if (point.getX() < this.minx) { this.minx = point.getX(); } if (point.getX() > this.maxx) { this.maxx = point.getX(); } if (point.getY() < this.miny) { this.miny = point.getY(); } if (point.getY() > this.maxy) { this.maxy = point.getY(); } if (point.getZ() < this.minz) { this.minz = point.getZ(); } if (point.getZ() > this.maxz) { this.maxz = point.getZ(); } if (point.getM() < this.minm) { this.minm = point.getM(); } if (point.getM() > this.maxm) { this.maxm = point.getM(); } }
java
{ "resource": "" }
q14783
ESRIBounds.toRectangle2d
train
@Pure public Rectangle2d toRectangle2d() { final Rectangle2d bounds = new Rectangle2d(); bounds.setFromCorners(this.minx, this.miny, this.maxx, this.maxy); return bounds; }
java
{ "resource": "" }
q14784
ESRIBounds.ensureMinMax
train
public void ensureMinMax() { double t; if (this.maxx < this.minx) { t = this.minx; this.minx = this.maxx; this.maxx = t; } if (this.maxy < this.miny) { t = this.miny; this.miny = this.maxy; this.maxy = t; } if (this.maxz < this.minz) { t = this.minz; this.minz = this.maxz; this.maxz = t; } if (this.maxm < this.minm) { t = this.minm; this.minm = this.maxm; this.maxm = t; } }
java
{ "resource": "" }
q14785
AbstractCommonShapeFileReader.getBoundsFromHeader
train
public ESRIBounds getBoundsFromHeader() { try { readHeader(); } catch (IOException exception) { return null; } return new ESRIBounds( this.minx, this.maxx, this.miny, this.maxy, this.minz, this.maxz, this.minm, this.maxm); }
java
{ "resource": "" }
q14786
AbstractCommonShapeFileReader.read
train
public E read() throws IOException { boolean status = false; try { // Read header if not already read readHeader(); // Read the records E element; try { do { element = readRecord(this.nextExpectedRecordIndex); if (!postRecordReadingStage(element)) { element = null; } ++this.nextExpectedRecordIndex; } while (element == null); } catch (EOFException e) { element = null; close(); postReadingStage(true); } status = true; return element; } finally { if (this.taskProgression != null) { this.taskProgression.setValue(this.buffer.position() + HEADER_BYTES); } if (!status) { close(); postReadingStage(status); } } }
java
{ "resource": "" }
q14787
AbstractCommonShapeFileReader.setReadingPosition
train
protected void setReadingPosition(int recordIndex, int byteIndex) throws IOException { if (this.seekEnabled) { this.nextExpectedRecordIndex = recordIndex; this.buffer.position(byteIndex); } else { throw new SeekOperationDisabledException(); } }
java
{ "resource": "" }
q14788
AbstractCommonShapeFileReader.ensureAvailableBytes
train
protected void ensureAvailableBytes(int amount) throws IOException { if (!this.seekEnabled && amount > this.buffer.remaining()) { this.bufferPosition += this.buffer.position(); this.buffer.compact(); int limit = this.buffer.position(); final int read = this.stream.read(this.buffer); if (read < 0) { if (limit == 0) { throw new EOFException(); } } else { limit += read; } this.buffer.rewind(); this.buffer.limit(limit); } if (amount > this.buffer.remaining()) { throw new EOFException(); } }
java
{ "resource": "" }
q14789
AbstractCommonShapeFileReader.skipBytes
train
protected void skipBytes(int amount) throws IOException { ensureAvailableBytes(amount); this.buffer.position(this.buffer.position() + amount); }
java
{ "resource": "" }
q14790
AbstractTargetPositionPredictionAlgorithm.predictTargetPosition
train
@Pure public Point2D<?, ?> predictTargetPosition(Point2D<?, ?> targetPosition, Vector2D<?, ?> targetLinearMotion) { return new Point2d( targetPosition.getX() + targetLinearMotion.getX() * this.predictionDuration, targetPosition.getY() + targetLinearMotion.getY() * this.predictionDuration); }
java
{ "resource": "" }
q14791
HandlerSocketHandler.reconnect
train
protected void reconnect(Session session) { if (this.hsClient.isStarted()) { if (log.isDebugEnabled()) { log.debug("Add reconnectRequest to connector " + session.getRemoteSocketAddress()); } HandlerSocketSession hSession = (HandlerSocketSession) session; InetSocketAddress addr = hSession.getRemoteSocketAddress(); this.hsClient.getConnector().addToWatingQueue( new ReconnectRequest(addr, 0, this.hsClient .getHealConnectionInterval())); } }
java
{ "resource": "" }
q14792
AStar.setSegmentReplacer
train
public AStarSegmentReplacer<ST> setSegmentReplacer(AStarSegmentReplacer<ST> replacer) { final AStarSegmentReplacer<ST> old = this.segmentReplacer; this.segmentReplacer = replacer; return old; }
java
{ "resource": "" }
q14793
AStar.setSegmentOrientationTool
train
public AStarSegmentOrientation<ST, PT> setSegmentOrientationTool(AStarSegmentOrientation<ST, PT> tool) { final AStarSegmentOrientation<ST, PT> old = this.segmentOrientation; this.segmentOrientation = tool; return old; }
java
{ "resource": "" }
q14794
AStar.setCostComputer
train
public AStarCostComputer<? super ST, ? super PT> setCostComputer(AStarCostComputer<? super ST, ? super PT> costComputer) { final AStarCostComputer<? super ST, ? super PT> old = this.costComputer; this.costComputer = costComputer; return old; }
java
{ "resource": "" }
q14795
AStar.estimate
train
@Pure protected double estimate(PT p1, PT p2) { assert p1 != null && p2 != null; if (this.heuristic == null) { throw new IllegalStateException(Locale.getString("E1")); //$NON-NLS-1$ } return this.heuristic.evaluate(p1, p2); }
java
{ "resource": "" }
q14796
AStar.computeCostFor
train
@Pure protected double computeCostFor(ST segment) { if (this.costComputer != null) { return this.costComputer.computeCostFor(segment); } return segment.getLength(); }
java
{ "resource": "" }
q14797
AStar.newPath
train
@SuppressWarnings({ "unchecked", "rawtypes" }) @Pure protected GP newPath(PT startPoint, ST segment) { if (this.pathFactory != null) { return this.pathFactory.newPath(startPoint, segment); } try { return (GP) new GraphPath(segment, startPoint); } catch (Throwable e) { throw new IllegalStateException(Locale.getString("E2"), e); //$NON-NLS-1$ } }
java
{ "resource": "" }
q14798
AStar.addToPath
train
protected boolean addToPath(GP path, ST segment) { if (this.pathFactory != null) { return this.pathFactory.addToPath(path, segment); } assert path != null; assert segment != null; try { return path.add(segment); } catch (Throwable e) { throw new IllegalStateException(e); } }
java
{ "resource": "" }
q14799
AStar.replaceSegment
train
@Pure protected ST replaceSegment(int index, ST segment) { ST rep = null; if (this.segmentReplacer != null) { rep = this.segmentReplacer.replaceSegment(index, segment); } if (rep == null) { rep = segment; } return rep; }
java
{ "resource": "" }