repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
jingwei/krati | krati-main/src/main/java/krati/core/array/basic/ArrayFile.java | ArrayFile.loadShortArray | public short[] loadShortArray() throws IOException {
if (!_file.exists() || _file.length() == 0) {
return null;
}
Chronos c = new Chronos();
DataReader r = IOFactory.createDataReader(_file, _type);
try {
r.open();
r.position(DATA_START_POSITION);
short[] array = new short[_arrayLength];
for (int i = 0; i < _arrayLength; i++) {
array[i] = r.readShort();
}
_log.info(_file.getName() + " loaded in " + c.getElapsedTime());
return array;
} finally {
r.close();
}
} | java | public short[] loadShortArray() throws IOException {
if (!_file.exists() || _file.length() == 0) {
return null;
}
Chronos c = new Chronos();
DataReader r = IOFactory.createDataReader(_file, _type);
try {
r.open();
r.position(DATA_START_POSITION);
short[] array = new short[_arrayLength];
for (int i = 0; i < _arrayLength; i++) {
array[i] = r.readShort();
}
_log.info(_file.getName() + " loaded in " + c.getElapsedTime());
return array;
} finally {
r.close();
}
} | [
"public",
"short",
"[",
"]",
"loadShortArray",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"_file",
".",
"exists",
"(",
")",
"||",
"_file",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"Chronos",
"c",
"=",
... | Loads the main array.
@return a short array
@throws IOException | [
"Loads",
"the",
"main",
"array",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/basic/ArrayFile.java#L464-L486 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/basic/ArrayFile.java | ArrayFile.update | public synchronized <T extends EntryValue> void update(List<Entry<T>> entryList)
throws IOException {
Chronos c = new Chronos();
// Sort values by position in the array file
T[] values = EntryUtility.sortEntriesToValues(entryList);
if (values == null || values.length == 0) return;
// Obtain maxScn
long maxScn = _arrayHwmScn;
for (Entry<?> e : entryList) {
maxScn = Math.max(e.getMaxScn(), maxScn);
}
// Write hwmScn
_log.info("write hwmScn:" + maxScn);
_writer.writeLong(HWM_SCN_POSITION, maxScn);
_writer.flush();
// Write values
for (T v : values) {
v.updateArrayFile(_writer, getPosition(v.pos));
}
_writer.flush();
// Write lwmScn
_log.info("write lwmScn:" + maxScn);
_writer.writeLong(LWM_SCN_POSITION, maxScn);
_writer.flush();
_arrayLwmScn = maxScn;
_arrayHwmScn = maxScn;
_log.info(entryList.size() + " entries flushed to " +
_file.getAbsolutePath() + " in " + c.getElapsedTime());
} | java | public synchronized <T extends EntryValue> void update(List<Entry<T>> entryList)
throws IOException {
Chronos c = new Chronos();
// Sort values by position in the array file
T[] values = EntryUtility.sortEntriesToValues(entryList);
if (values == null || values.length == 0) return;
// Obtain maxScn
long maxScn = _arrayHwmScn;
for (Entry<?> e : entryList) {
maxScn = Math.max(e.getMaxScn(), maxScn);
}
// Write hwmScn
_log.info("write hwmScn:" + maxScn);
_writer.writeLong(HWM_SCN_POSITION, maxScn);
_writer.flush();
// Write values
for (T v : values) {
v.updateArrayFile(_writer, getPosition(v.pos));
}
_writer.flush();
// Write lwmScn
_log.info("write lwmScn:" + maxScn);
_writer.writeLong(LWM_SCN_POSITION, maxScn);
_writer.flush();
_arrayLwmScn = maxScn;
_arrayHwmScn = maxScn;
_log.info(entryList.size() + " entries flushed to " +
_file.getAbsolutePath() + " in " + c.getElapsedTime());
} | [
"public",
"synchronized",
"<",
"T",
"extends",
"EntryValue",
">",
"void",
"update",
"(",
"List",
"<",
"Entry",
"<",
"T",
">",
">",
"entryList",
")",
"throws",
"IOException",
"{",
"Chronos",
"c",
"=",
"new",
"Chronos",
"(",
")",
";",
"// Sort values by posi... | Apply entries to the array file.
The method will flatten entry data and sort it by position.
So the array file can be updated sequentially to reduce disk seeking time.
This method updates hwmScn and lwmScn in the array file.
@param entryList
@throws IOException | [
"Apply",
"entries",
"to",
"the",
"array",
"file",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/basic/ArrayFile.java#L547-L582 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/basic/ArrayFile.java | ArrayFile.setWaterMarks | public void setWaterMarks(long lwmScn, long hwmScn) throws IOException {
if(lwmScn <= hwmScn) {
writeHwmScn(hwmScn);
_writer.flush();
writeLwmScn(lwmScn);
_writer.flush();
} else {
throw new IOException("Invalid water marks: lwmScn=" + lwmScn + " hwmScn=" + hwmScn);
}
} | java | public void setWaterMarks(long lwmScn, long hwmScn) throws IOException {
if(lwmScn <= hwmScn) {
writeHwmScn(hwmScn);
_writer.flush();
writeLwmScn(lwmScn);
_writer.flush();
} else {
throw new IOException("Invalid water marks: lwmScn=" + lwmScn + " hwmScn=" + hwmScn);
}
} | [
"public",
"void",
"setWaterMarks",
"(",
"long",
"lwmScn",
",",
"long",
"hwmScn",
")",
"throws",
"IOException",
"{",
"if",
"(",
"lwmScn",
"<=",
"hwmScn",
")",
"{",
"writeHwmScn",
"(",
"hwmScn",
")",
";",
"_writer",
".",
"flush",
"(",
")",
";",
"writeLwmSc... | Sets the water marks of this ArrayFile.
@param lwmScn - the low water mark
@param hwmScn - the high water mark
@throws IOException if the <code>lwmScn</code> is greater than the <code>hwmScn</code>
or the changes to the underlying file cannot be flushed. | [
"Sets",
"the",
"water",
"marks",
"of",
"this",
"ArrayFile",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/basic/ArrayFile.java#L617-L626 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/basic/ArrayFile.java | ArrayFile.resetAll | public synchronized void resetAll(long value) throws IOException {
if(_elementSize != 8) {
throw new IOException("Operation aborted: elementSize=" + _elementSize);
}
_writer.flush();
_writer.position(DATA_START_POSITION);
for(int i = 0; i < this._arrayLength; i++) {
_writer.writeLong(value);
}
_writer.flush();
} | java | public synchronized void resetAll(long value) throws IOException {
if(_elementSize != 8) {
throw new IOException("Operation aborted: elementSize=" + _elementSize);
}
_writer.flush();
_writer.position(DATA_START_POSITION);
for(int i = 0; i < this._arrayLength; i++) {
_writer.writeLong(value);
}
_writer.flush();
} | [
"public",
"synchronized",
"void",
"resetAll",
"(",
"long",
"value",
")",
"throws",
"IOException",
"{",
"if",
"(",
"_elementSize",
"!=",
"8",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Operation aborted: elementSize=\"",
"+",
"_elementSize",
")",
";",
"}",
... | Resets all element values to the specified long value.
@param value - the element value.
@throws IOException | [
"Resets",
"all",
"element",
"values",
"to",
"the",
"specified",
"long",
"value",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/basic/ArrayFile.java#L820-L831 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/basic/ArrayFile.java | ArrayFile.setArrayLength | public synchronized void setArrayLength(int arrayLength, File renameToFile) throws IOException {
if(arrayLength < 0) {
throw new IOException("Invalid array length: " + arrayLength);
}
if(this._arrayLength == arrayLength) return;
// Flush all the changes.
this.flush();
// Change the file length.
long fileLength = DATA_START_POSITION + ((long)arrayLength * _elementSize);
RandomAccessFile raf = new RandomAccessFile(_file, "rw");
try {
raf.setLength(fileLength);
} catch(IOException e) {
_log.error("failed to setArrayLength " + arrayLength);
throw e;
} finally {
raf.close();
}
// Write the new array length.
writeArrayLength(arrayLength);
this.flush();
if(renameToFile != null) {
if(_file.renameTo(renameToFile)) {
_writer.close();
_file = renameToFile;
_writer = IOFactory.createDataWriter(_file, _type);
_writer.open();
return;
} else {
_log.warn("Failed to rename " + _file.getAbsolutePath() + " to " + renameToFile.getAbsolutePath());
}
}
if(MultiMappedWriter.class.isInstance(_writer)) {
((MultiMappedWriter)_writer).remap();
_log.info("remap " + _file.getPath() + " " + _file.length());
} else {
_writer.close();
_writer = IOFactory.createDataWriter(_file, _type);
_writer.open();
}
} | java | public synchronized void setArrayLength(int arrayLength, File renameToFile) throws IOException {
if(arrayLength < 0) {
throw new IOException("Invalid array length: " + arrayLength);
}
if(this._arrayLength == arrayLength) return;
// Flush all the changes.
this.flush();
// Change the file length.
long fileLength = DATA_START_POSITION + ((long)arrayLength * _elementSize);
RandomAccessFile raf = new RandomAccessFile(_file, "rw");
try {
raf.setLength(fileLength);
} catch(IOException e) {
_log.error("failed to setArrayLength " + arrayLength);
throw e;
} finally {
raf.close();
}
// Write the new array length.
writeArrayLength(arrayLength);
this.flush();
if(renameToFile != null) {
if(_file.renameTo(renameToFile)) {
_writer.close();
_file = renameToFile;
_writer = IOFactory.createDataWriter(_file, _type);
_writer.open();
return;
} else {
_log.warn("Failed to rename " + _file.getAbsolutePath() + " to " + renameToFile.getAbsolutePath());
}
}
if(MultiMappedWriter.class.isInstance(_writer)) {
((MultiMappedWriter)_writer).remap();
_log.info("remap " + _file.getPath() + " " + _file.length());
} else {
_writer.close();
_writer = IOFactory.createDataWriter(_file, _type);
_writer.open();
}
} | [
"public",
"synchronized",
"void",
"setArrayLength",
"(",
"int",
"arrayLength",
",",
"File",
"renameToFile",
")",
"throws",
"IOException",
"{",
"if",
"(",
"arrayLength",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Invalid array length: \"",
"+",
"a... | Updates the length of this ArrayFile to the specified value.
@param arrayLength - the new array length
@param renameToFile - the copy of this ArrayFile. If <code>null</code>, no backup copy will be created.
@throws IOException | [
"Updates",
"the",
"length",
"of",
"this",
"ArrayFile",
"to",
"the",
"specified",
"value",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/basic/ArrayFile.java#L866-L912 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cobol/model/CobolUsage.java | CobolUsage.getUsage | public static Usage getUsage(String cobolUsage) {
if (cobolUsage == null) {
return null;
}
if (cobolUsage.equals(BINARY)) {
return Usage.BINARY;
} else if (cobolUsage.equals("COMP")) {
return Usage.BINARY;
} else if (cobolUsage.equals("COMPUTATIONAL")) {
return Usage.BINARY;
} else if (cobolUsage.equals("COMP-4")) {
return Usage.BINARY;
} else if (cobolUsage.equals("COMPUTATIONAL-4")) {
return Usage.BINARY;
} else if (cobolUsage.equals(COMP_1)) {
return Usage.SINGLEFLOAT;
} else if (cobolUsage.equals(COMP_2)) {
return Usage.DOUBLEFLOAT;
} else if (cobolUsage.equals(PACKED_DECIMAL)) {
return Usage.PACKEDDECIMAL;
} else if (cobolUsage.equals("PACKED-DECIMAL")) {
return Usage.PACKEDDECIMAL;
} else if (cobolUsage.equals("COMPUTATIONAL-3")) {
return Usage.PACKEDDECIMAL;
} else if (cobolUsage.equals(COMP_5)) {
return Usage.NATIVEBINARY;
} else if (cobolUsage.equals("COMPUTATIONAL-5")) {
return Usage.NATIVEBINARY;
} else if (cobolUsage.equals(DISPLAY)) {
return Usage.DISPLAY;
} else if (cobolUsage.equals(DISPLAY_1)) {
return Usage.DISPLAY1;
} else if (cobolUsage.equals(INDEX)) {
return Usage.INDEX;
} else if (cobolUsage.equals(NATIONAL)) {
return Usage.NATIONAL;
} else if (cobolUsage.equals(POINTER)) {
return Usage.POINTER;
} else if (cobolUsage.equals(PROCEDURE_POINTER)) {
return Usage.PROCEDUREPOINTER;
} else if (cobolUsage.equals(FUNCTION_POINTER)) {
return Usage.FUNCTIONPOINTER;
} else {
throw new IllegalArgumentException("Unknown COBOL usage: "
+ cobolUsage);
}
} | java | public static Usage getUsage(String cobolUsage) {
if (cobolUsage == null) {
return null;
}
if (cobolUsage.equals(BINARY)) {
return Usage.BINARY;
} else if (cobolUsage.equals("COMP")) {
return Usage.BINARY;
} else if (cobolUsage.equals("COMPUTATIONAL")) {
return Usage.BINARY;
} else if (cobolUsage.equals("COMP-4")) {
return Usage.BINARY;
} else if (cobolUsage.equals("COMPUTATIONAL-4")) {
return Usage.BINARY;
} else if (cobolUsage.equals(COMP_1)) {
return Usage.SINGLEFLOAT;
} else if (cobolUsage.equals(COMP_2)) {
return Usage.DOUBLEFLOAT;
} else if (cobolUsage.equals(PACKED_DECIMAL)) {
return Usage.PACKEDDECIMAL;
} else if (cobolUsage.equals("PACKED-DECIMAL")) {
return Usage.PACKEDDECIMAL;
} else if (cobolUsage.equals("COMPUTATIONAL-3")) {
return Usage.PACKEDDECIMAL;
} else if (cobolUsage.equals(COMP_5)) {
return Usage.NATIVEBINARY;
} else if (cobolUsage.equals("COMPUTATIONAL-5")) {
return Usage.NATIVEBINARY;
} else if (cobolUsage.equals(DISPLAY)) {
return Usage.DISPLAY;
} else if (cobolUsage.equals(DISPLAY_1)) {
return Usage.DISPLAY1;
} else if (cobolUsage.equals(INDEX)) {
return Usage.INDEX;
} else if (cobolUsage.equals(NATIONAL)) {
return Usage.NATIONAL;
} else if (cobolUsage.equals(POINTER)) {
return Usage.POINTER;
} else if (cobolUsage.equals(PROCEDURE_POINTER)) {
return Usage.PROCEDUREPOINTER;
} else if (cobolUsage.equals(FUNCTION_POINTER)) {
return Usage.FUNCTIONPOINTER;
} else {
throw new IllegalArgumentException("Unknown COBOL usage: "
+ cobolUsage);
}
} | [
"public",
"static",
"Usage",
"getUsage",
"(",
"String",
"cobolUsage",
")",
"{",
"if",
"(",
"cobolUsage",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"cobolUsage",
".",
"equals",
"(",
"BINARY",
")",
")",
"{",
"return",
"Usage",
".",
... | Get the java enumeration corresponding to a COBOL usage string.
@param cobolUsage the COBOL usage string
@return the java enumeration | [
"Get",
"the",
"java",
"enumeration",
"corresponding",
"to",
"a",
"COBOL",
"usage",
"string",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cobol/model/CobolUsage.java#L128-L175 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDMAuditor.java | XDMAuditor.getAuditor | public static XDMAuditor getAuditor()
{
AuditorModuleContext ctx = AuditorModuleContext.getContext();
return (XDMAuditor)ctx.getAuditor(XDMAuditor.class);
} | java | public static XDMAuditor getAuditor()
{
AuditorModuleContext ctx = AuditorModuleContext.getContext();
return (XDMAuditor)ctx.getAuditor(XDMAuditor.class);
} | [
"public",
"static",
"XDMAuditor",
"getAuditor",
"(",
")",
"{",
"AuditorModuleContext",
"ctx",
"=",
"AuditorModuleContext",
".",
"getContext",
"(",
")",
";",
"return",
"(",
"XDMAuditor",
")",
"ctx",
".",
"getAuditor",
"(",
"XDMAuditor",
".",
"class",
")",
";",
... | Get an instance of the XDM auditor from the
global context
@return XDM auditor instance | [
"Get",
"an",
"instance",
"of",
"the",
"XDM",
"auditor",
"from",
"the",
"global",
"context"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDMAuditor.java#L38-L42 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDMAuditor.java | XDMAuditor.auditPortableMediaImport | public void auditPortableMediaImport(
RFC3881EventOutcomeCodes eventOutcome,
String submissionSetUniqueId,
String patientId,
List<CodedValueType> purposesOfUse)
{
if (!isAuditorEnabled()) {
return;
}
ImportEvent importEvent = new ImportEvent(false, eventOutcome, new IHETransactionEventTypeCodes.DistributeDocumentSetOnMedia(), purposesOfUse);
importEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
importEvent.addDestinationActiveParticipant(getSystemUserId(), getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), false);
if (!EventUtils.isEmptyOrNull(patientId)) {
importEvent.addPatientParticipantObject(patientId);
}
importEvent.addSubmissionSetParticipantObject(submissionSetUniqueId);
audit(importEvent);
} | java | public void auditPortableMediaImport(
RFC3881EventOutcomeCodes eventOutcome,
String submissionSetUniqueId,
String patientId,
List<CodedValueType> purposesOfUse)
{
if (!isAuditorEnabled()) {
return;
}
ImportEvent importEvent = new ImportEvent(false, eventOutcome, new IHETransactionEventTypeCodes.DistributeDocumentSetOnMedia(), purposesOfUse);
importEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
importEvent.addDestinationActiveParticipant(getSystemUserId(), getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), false);
if (!EventUtils.isEmptyOrNull(patientId)) {
importEvent.addPatientParticipantObject(patientId);
}
importEvent.addSubmissionSetParticipantObject(submissionSetUniqueId);
audit(importEvent);
} | [
"public",
"void",
"auditPortableMediaImport",
"(",
"RFC3881EventOutcomeCodes",
"eventOutcome",
",",
"String",
"submissionSetUniqueId",
",",
"String",
"patientId",
",",
"List",
"<",
"CodedValueType",
">",
"purposesOfUse",
")",
"{",
"if",
"(",
"!",
"isAuditorEnabled",
"... | Audits a PHI Import event for the IHE XDM Portable Media Importer
actor and ITI-32 Distribute Document Set on Media Transaction.
@param eventOutcome The event outcome indicator
@param submissionSetUniqueId The Unique ID of the Submission Set imported
@param patientId The ID of the Patient to which the Submission Set pertains | [
"Audits",
"a",
"PHI",
"Import",
"event",
"for",
"the",
"IHE",
"XDM",
"Portable",
"Media",
"Importer",
"actor",
"and",
"ITI",
"-",
"32",
"Distribute",
"Document",
"Set",
"on",
"Media",
"Transaction",
"."
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDMAuditor.java#L53-L71 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDMAuditor.java | XDMAuditor.auditPortableMediaCreate | public void auditPortableMediaCreate(
RFC3881EventOutcomeCodes eventOutcome,
String submissionSetUniqueId,
String patientId,
List<CodedValueType> purposesOfUse)
{
if (!isAuditorEnabled()) {
return;
}
ExportEvent exportEvent = new ExportEvent(true, eventOutcome, new IHETransactionEventTypeCodes.DistributeDocumentSetOnMedia(), purposesOfUse);
exportEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
exportEvent.addSourceActiveParticipant(getSystemUserId(), getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), true);
if (!EventUtils.isEmptyOrNull(patientId)) {
exportEvent.addPatientParticipantObject(patientId);
}
exportEvent.addSubmissionSetParticipantObject(submissionSetUniqueId);
audit(exportEvent);
} | java | public void auditPortableMediaCreate(
RFC3881EventOutcomeCodes eventOutcome,
String submissionSetUniqueId,
String patientId,
List<CodedValueType> purposesOfUse)
{
if (!isAuditorEnabled()) {
return;
}
ExportEvent exportEvent = new ExportEvent(true, eventOutcome, new IHETransactionEventTypeCodes.DistributeDocumentSetOnMedia(), purposesOfUse);
exportEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
exportEvent.addSourceActiveParticipant(getSystemUserId(), getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), true);
if (!EventUtils.isEmptyOrNull(patientId)) {
exportEvent.addPatientParticipantObject(patientId);
}
exportEvent.addSubmissionSetParticipantObject(submissionSetUniqueId);
audit(exportEvent);
} | [
"public",
"void",
"auditPortableMediaCreate",
"(",
"RFC3881EventOutcomeCodes",
"eventOutcome",
",",
"String",
"submissionSetUniqueId",
",",
"String",
"patientId",
",",
"List",
"<",
"CodedValueType",
">",
"purposesOfUse",
")",
"{",
"if",
"(",
"!",
"isAuditorEnabled",
"... | Audits a PHI Export event for the IHE XDM Portable Media Creator actor,
ITI-32 Distribute Document Set on Media transaction.
@param eventOutcome The event outcome indicator
@param submissionSetUniqueId The Unique ID of the Submission Set exported
@param patientId The ID of the Patient to which the Submission Set pertains | [
"Audits",
"a",
"PHI",
"Export",
"event",
"for",
"the",
"IHE",
"XDM",
"Portable",
"Media",
"Creator",
"actor",
"ITI",
"-",
"32",
"Distribute",
"Document",
"Set",
"on",
"Media",
"transaction",
"."
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDMAuditor.java#L81-L98 | train |
jingwei/krati | krati-main/src/main/java/krati/util/Chronos.java | Chronos.tick | public long tick() {
long tick = System.currentTimeMillis();
long diff = tick - _lastTick;
_lastTick = tick;
return diff;
} | java | public long tick() {
long tick = System.currentTimeMillis();
long diff = tick - _lastTick;
_lastTick = tick;
return diff;
} | [
"public",
"long",
"tick",
"(",
")",
"{",
"long",
"tick",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"long",
"diff",
"=",
"tick",
"-",
"_lastTick",
";",
"_lastTick",
"=",
"tick",
";",
"return",
"diff",
";",
"}"
] | Returns the number of milliseconds elapsed since the last call to this
function.
@return the number of milliseconds since last call | [
"Returns",
"the",
"number",
"of",
"milliseconds",
"elapsed",
"since",
"the",
"last",
"call",
"to",
"this",
"function",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/util/Chronos.java#L76-L82 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java | Cob2Xsd.translate | public String translate(final Reader cobolReader,
final String targetNamespace, final String xsltFileName)
throws XsdGenerationException {
try {
if (_log.isDebugEnabled()) {
_log.debug("Translating with options: {}", getConfig()
.toString());
_log.debug("Target namespace: {}", targetNamespace);
}
return xsdToString(emitXsd(toModel(cobolReader), targetNamespace),
xsltFileName);
} catch (RecognizerException e) {
throw new XsdGenerationException(e);
}
} | java | public String translate(final Reader cobolReader,
final String targetNamespace, final String xsltFileName)
throws XsdGenerationException {
try {
if (_log.isDebugEnabled()) {
_log.debug("Translating with options: {}", getConfig()
.toString());
_log.debug("Target namespace: {}", targetNamespace);
}
return xsdToString(emitXsd(toModel(cobolReader), targetNamespace),
xsltFileName);
} catch (RecognizerException e) {
throw new XsdGenerationException(e);
}
} | [
"public",
"String",
"translate",
"(",
"final",
"Reader",
"cobolReader",
",",
"final",
"String",
"targetNamespace",
",",
"final",
"String",
"xsltFileName",
")",
"throws",
"XsdGenerationException",
"{",
"try",
"{",
"if",
"(",
"_log",
".",
"isDebugEnabled",
"(",
")... | Execute the translation from COBOL to XML Schema.
@param cobolReader reads the raw COBOL source
@param targetNamespace the generated XML schema target namespace (null
for no namespace)
@param xsltFileName an optional xslt to apply on the XML Schema
@return the XML Schema
@throws XsdGenerationException if XML schema generation process fails | [
"Execute",
"the",
"translation",
"from",
"COBOL",
"to",
"XML",
"Schema",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java#L115-L129 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java | Cob2Xsd.toModel | public List < CobolDataItem > toModel(final Reader cobolReader)
throws RecognizerException {
return emitModel(parse(lex(clean(cobolReader))));
} | java | public List < CobolDataItem > toModel(final Reader cobolReader)
throws RecognizerException {
return emitModel(parse(lex(clean(cobolReader))));
} | [
"public",
"List",
"<",
"CobolDataItem",
">",
"toModel",
"(",
"final",
"Reader",
"cobolReader",
")",
"throws",
"RecognizerException",
"{",
"return",
"emitModel",
"(",
"parse",
"(",
"lex",
"(",
"clean",
"(",
"cobolReader",
")",
")",
")",
")",
";",
"}"
] | Parses a COBOL source into an in-memory model.
@param cobolReader reads the raw COBOL source
@return a list of root COBOL data items
@throws RecognizerException if COBOL recognition fails | [
"Parses",
"a",
"COBOL",
"source",
"into",
"an",
"in",
"-",
"memory",
"model",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java#L138-L141 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java | Cob2Xsd.clean | public String clean(final Reader cobolReader) throws CleanerException {
if (_log.isDebugEnabled()) {
_log.debug("1. Cleaning COBOL source code");
}
switch (getConfig().getCodeFormat()) {
case FIXED_FORMAT:
CobolFixedFormatSourceCleaner fixedCleaner = new CobolFixedFormatSourceCleaner(
getErrorHandler(), getConfig().getStartColumn(), getConfig()
.getEndColumn());
return fixedCleaner.clean(cobolReader);
case FREE_FORMAT:
CobolFreeFormatSourceCleaner freeCleaner = new CobolFreeFormatSourceCleaner(
getErrorHandler());
return freeCleaner.clean(cobolReader);
default:
throw new CleanerException("Unkown COBOL source format "
+ getConfig().getCodeFormat());
}
} | java | public String clean(final Reader cobolReader) throws CleanerException {
if (_log.isDebugEnabled()) {
_log.debug("1. Cleaning COBOL source code");
}
switch (getConfig().getCodeFormat()) {
case FIXED_FORMAT:
CobolFixedFormatSourceCleaner fixedCleaner = new CobolFixedFormatSourceCleaner(
getErrorHandler(), getConfig().getStartColumn(), getConfig()
.getEndColumn());
return fixedCleaner.clean(cobolReader);
case FREE_FORMAT:
CobolFreeFormatSourceCleaner freeCleaner = new CobolFreeFormatSourceCleaner(
getErrorHandler());
return freeCleaner.clean(cobolReader);
default:
throw new CleanerException("Unkown COBOL source format "
+ getConfig().getCodeFormat());
}
} | [
"public",
"String",
"clean",
"(",
"final",
"Reader",
"cobolReader",
")",
"throws",
"CleanerException",
"{",
"if",
"(",
"_log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"_log",
".",
"debug",
"(",
"\"1. Cleaning COBOL source code\"",
")",
";",
"}",
"switch",
... | Remove any non COBOL Structure characters from the source.
@param cobolReader reads the raw COBOL source
@return a cleaned up source
@throws CleanerException if source cannot be read | [
"Remove",
"any",
"non",
"COBOL",
"Structure",
"characters",
"from",
"the",
"source",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java#L150-L168 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java | Cob2Xsd.lex | public CommonTokenStream lex(final String cleanedCobolSource)
throws RecognizerException {
if (_log.isDebugEnabled()) {
_log.debug("2. Lexing COBOL source code: {}", cleanedCobolSource);
}
try {
CobolStructureLexer lex = new CobolStructureLexerImpl(
new ANTLRReaderStream(new StringReader(cleanedCobolSource)),
getErrorHandler());
CommonTokenStream tokens = new CommonTokenStream(lex);
if (lex.getNumberOfSyntaxErrors() != 0 || tokens == null) {
throw (new RecognizerException("Lexing failed. "
+ lex.getNumberOfSyntaxErrors() + " syntax errors."
+ " Last error was "
+ getErrorHistory().get(getErrorHistory().size() - 1)));
}
return tokens;
} catch (IOException e) {
throw (new RecognizerException(e));
}
} | java | public CommonTokenStream lex(final String cleanedCobolSource)
throws RecognizerException {
if (_log.isDebugEnabled()) {
_log.debug("2. Lexing COBOL source code: {}", cleanedCobolSource);
}
try {
CobolStructureLexer lex = new CobolStructureLexerImpl(
new ANTLRReaderStream(new StringReader(cleanedCobolSource)),
getErrorHandler());
CommonTokenStream tokens = new CommonTokenStream(lex);
if (lex.getNumberOfSyntaxErrors() != 0 || tokens == null) {
throw (new RecognizerException("Lexing failed. "
+ lex.getNumberOfSyntaxErrors() + " syntax errors."
+ " Last error was "
+ getErrorHistory().get(getErrorHistory().size() - 1)));
}
return tokens;
} catch (IOException e) {
throw (new RecognizerException(e));
}
} | [
"public",
"CommonTokenStream",
"lex",
"(",
"final",
"String",
"cleanedCobolSource",
")",
"throws",
"RecognizerException",
"{",
"if",
"(",
"_log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"_log",
".",
"debug",
"(",
"\"2. Lexing COBOL source code: {}\"",
",",
"cle... | Apply the lexer to produce a token stream from source.
@param cleanedCobolSource the source code (clean outside columns 7 to 72)
@return an antlr token stream
@throws RecognizerException if lexer failed to tokenize COBOL source | [
"Apply",
"the",
"lexer",
"to",
"produce",
"a",
"token",
"stream",
"from",
"source",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java#L177-L197 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java | Cob2Xsd.parse | public CommonTree parse(final CommonTokenStream tokens)
throws RecognizerException {
if (_log.isDebugEnabled()) {
_log.debug("3. Parsing tokens: {}", tokens.toString());
}
try {
CobolStructureParser parser = new CobolStructureParserImpl(tokens,
getErrorHandler());
cobdata_return parserResult = parser.cobdata();
if (parser.getNumberOfSyntaxErrors() != 0 || parserResult == null) {
throw (new RecognizerException("Parsing failed. "
+ parser.getNumberOfSyntaxErrors() + " syntax errors."
+ " Last error was "
+ getErrorHistory().get(getErrorHistory().size() - 1)));
}
return (CommonTree) parserResult.getTree();
} catch (RecognitionException e) {
throw (new RecognizerException(e));
}
} | java | public CommonTree parse(final CommonTokenStream tokens)
throws RecognizerException {
if (_log.isDebugEnabled()) {
_log.debug("3. Parsing tokens: {}", tokens.toString());
}
try {
CobolStructureParser parser = new CobolStructureParserImpl(tokens,
getErrorHandler());
cobdata_return parserResult = parser.cobdata();
if (parser.getNumberOfSyntaxErrors() != 0 || parserResult == null) {
throw (new RecognizerException("Parsing failed. "
+ parser.getNumberOfSyntaxErrors() + " syntax errors."
+ " Last error was "
+ getErrorHistory().get(getErrorHistory().size() - 1)));
}
return (CommonTree) parserResult.getTree();
} catch (RecognitionException e) {
throw (new RecognizerException(e));
}
} | [
"public",
"CommonTree",
"parse",
"(",
"final",
"CommonTokenStream",
"tokens",
")",
"throws",
"RecognizerException",
"{",
"if",
"(",
"_log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"_log",
".",
"debug",
"(",
"\"3. Parsing tokens: {}\"",
",",
"tokens",
".",
"... | Apply Parser to produce an abstract syntax tree from a token stream.
@param tokens the stream token produced by lexer
@return an antlr abstract syntax tree
@throws RecognizerException if source contains unsupported statements | [
"Apply",
"Parser",
"to",
"produce",
"an",
"abstract",
"syntax",
"tree",
"from",
"a",
"token",
"stream",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java#L206-L225 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java | Cob2Xsd.emitModel | public List < CobolDataItem > emitModel(final CommonTree ast)
throws RecognizerException {
List < CobolDataItem > cobolDataItems = new ArrayList < CobolDataItem >();
if (_log.isDebugEnabled()) {
_log.debug("4. Emitting Model from AST: {}",
((ast == null) ? "null" : ast.toStringTree()));
}
if (ast == null) {
return cobolDataItems;
}
try {
TreeNodeStream nodes = new CommonTreeNodeStream(ast);
CobolStructureEmitter emitter = new CobolStructureEmitterImpl(
nodes, getErrorHandler());
emitter.cobdata(cobolDataItems);
return cobolDataItems;
} catch (RecognitionException e) {
throw new RecognizerException(e);
}
} | java | public List < CobolDataItem > emitModel(final CommonTree ast)
throws RecognizerException {
List < CobolDataItem > cobolDataItems = new ArrayList < CobolDataItem >();
if (_log.isDebugEnabled()) {
_log.debug("4. Emitting Model from AST: {}",
((ast == null) ? "null" : ast.toStringTree()));
}
if (ast == null) {
return cobolDataItems;
}
try {
TreeNodeStream nodes = new CommonTreeNodeStream(ast);
CobolStructureEmitter emitter = new CobolStructureEmitterImpl(
nodes, getErrorHandler());
emitter.cobdata(cobolDataItems);
return cobolDataItems;
} catch (RecognitionException e) {
throw new RecognizerException(e);
}
} | [
"public",
"List",
"<",
"CobolDataItem",
">",
"emitModel",
"(",
"final",
"CommonTree",
"ast",
")",
"throws",
"RecognizerException",
"{",
"List",
"<",
"CobolDataItem",
">",
"cobolDataItems",
"=",
"new",
"ArrayList",
"<",
"CobolDataItem",
">",
"(",
")",
";",
"if"... | Generates a model from an Abstract Syntax Tree.
@param ast the abstract syntax tree produced by parser
@return a list of root COBOL data items
@throws RecognizerException if tree cannot be walked | [
"Generates",
"a",
"model",
"from",
"an",
"Abstract",
"Syntax",
"Tree",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java#L234-L253 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java | Cob2Xsd.getNonUniqueCobolNames | public static List < String > getNonUniqueCobolNames(
final List < CobolDataItem > cobolDataItems) {
List < String > cobolNames = new ArrayList < String >();
List < String > nonUniqueCobolNames = new ArrayList < String >();
for (CobolDataItem cobolDataItem : cobolDataItems) {
getNonUniqueCobolNames(cobolDataItem, cobolNames,
nonUniqueCobolNames);
}
return nonUniqueCobolNames;
} | java | public static List < String > getNonUniqueCobolNames(
final List < CobolDataItem > cobolDataItems) {
List < String > cobolNames = new ArrayList < String >();
List < String > nonUniqueCobolNames = new ArrayList < String >();
for (CobolDataItem cobolDataItem : cobolDataItems) {
getNonUniqueCobolNames(cobolDataItem, cobolNames,
nonUniqueCobolNames);
}
return nonUniqueCobolNames;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getNonUniqueCobolNames",
"(",
"final",
"List",
"<",
"CobolDataItem",
">",
"cobolDataItems",
")",
"{",
"List",
"<",
"String",
">",
"cobolNames",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"Li... | Create a list of COBOL names which are not unique. This is useful when we
build complex type names from the COBOL names. Complex type names need to
be unique within a target namespace.
@param cobolDataItems a list of root data items
@return a list of COBOL names which are not unique | [
"Create",
"a",
"list",
"of",
"COBOL",
"names",
"which",
"are",
"not",
"unique",
".",
"This",
"is",
"useful",
"when",
"we",
"build",
"complex",
"type",
"names",
"from",
"the",
"COBOL",
"names",
".",
"Complex",
"type",
"names",
"need",
"to",
"be",
"unique"... | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2Xsd.java#L355-L364 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/sender/TLSSyslogSenderImpl.java | TLSSyslogSenderImpl.getTLSSocket | private Socket getTLSSocket(InetAddress destination, int port) throws Exception
{
String key = destination.getHostAddress() + ":" + port;
synchronized (socketMap){
Socket socket = socketMap.get(key);
if (socket == null){
// create a new one
NodeAuthModuleContext nodeAuthContext = NodeAuthModuleContext.getContext();
socket = nodeAuthContext.getSocketHandler().getSocket(destination.getHostName(), port, true);
// remember it for next time
// TODO: had trouble with this with Steve Moore's online ATNA server so not caching the sockets
// need to worry about synchronization if we try to put this optimization back
// there appears to be one AuditorModuleContext per host/port so may can pool them based on that object?
socketMap.put(key, socket);
}
// whatever happened, now return the socket
return socket;
}
} | java | private Socket getTLSSocket(InetAddress destination, int port) throws Exception
{
String key = destination.getHostAddress() + ":" + port;
synchronized (socketMap){
Socket socket = socketMap.get(key);
if (socket == null){
// create a new one
NodeAuthModuleContext nodeAuthContext = NodeAuthModuleContext.getContext();
socket = nodeAuthContext.getSocketHandler().getSocket(destination.getHostName(), port, true);
// remember it for next time
// TODO: had trouble with this with Steve Moore's online ATNA server so not caching the sockets
// need to worry about synchronization if we try to put this optimization back
// there appears to be one AuditorModuleContext per host/port so may can pool them based on that object?
socketMap.put(key, socket);
}
// whatever happened, now return the socket
return socket;
}
} | [
"private",
"Socket",
"getTLSSocket",
"(",
"InetAddress",
"destination",
",",
"int",
"port",
")",
"throws",
"Exception",
"{",
"String",
"key",
"=",
"destination",
".",
"getHostAddress",
"(",
")",
"+",
"\":\"",
"+",
"port",
";",
"synchronized",
"(",
"socketMap",... | Gets the socket tied to the address and port for this transport
@param port Port to check
@return Port to use | [
"Gets",
"the",
"socket",
"tied",
"to",
"the",
"address",
"and",
"port",
"for",
"this",
"transport"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/sender/TLSSyslogSenderImpl.java#L171-L189 | train |
apptik/jus | jus-java/src/main/java/io/apptik/comm/jus/toolbox/DiskBasedCache.java | DiskBasedCache.clear | @Override
public synchronized void clear() {
File[] files = mRootDirectory.listFiles();
if (files != null) {
for (File file : files) {
file.delete();
}
}
mEntries.clear();
mTotalSize = 0;
//todo add queue markers
//JusLog.d("Cache cleared.");
} | java | @Override
public synchronized void clear() {
File[] files = mRootDirectory.listFiles();
if (files != null) {
for (File file : files) {
file.delete();
}
}
mEntries.clear();
mTotalSize = 0;
//todo add queue markers
//JusLog.d("Cache cleared.");
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"clear",
"(",
")",
"{",
"File",
"[",
"]",
"files",
"=",
"mRootDirectory",
".",
"listFiles",
"(",
")",
";",
"if",
"(",
"files",
"!=",
"null",
")",
"{",
"for",
"(",
"File",
"file",
":",
"files",
")",
... | Clears the cache. Deletes all cached files from disk. | [
"Clears",
"the",
"cache",
".",
"Deletes",
"all",
"cached",
"files",
"from",
"disk",
"."
] | 8a37a21b41f897d68eaeaab07368ec22a1e5a60e | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/jus-java/src/main/java/io/apptik/comm/jus/toolbox/DiskBasedCache.java#L107-L119 | train |
apptik/jus | jus-java/src/main/java/io/apptik/comm/jus/toolbox/DiskBasedCache.java | DiskBasedCache.get | @Override
public synchronized Entry get(String key) {
CacheHeader entry = mEntries.get(key);
// if the entry does not exist, return.
if (entry == null) {
return null;
}
File file = getFileForKey(key);
CountingInputStream cis = null;
try {
cis = new CountingInputStream(new BufferedInputStream(new FileInputStream(file)));
CacheHeader.readHeader(cis); // eat header
byte[] data = streamToBytes(cis, (int) (file.length() - cis.bytesRead));
return entry.toCacheEntry(data);
} catch (IOException e) {
//todo add queue markers
JusLog.log(file.getAbsolutePath() + ": " + e.toString());
remove(key);
return null;
} catch (NegativeArraySizeException e) {
JusLog.log(file.getAbsolutePath() + ": " + e.toString());
remove(key);
return null;
} finally {
if (cis != null) {
try {
cis.close();
} catch (IOException ioe) {
return null;
}
}
}
} | java | @Override
public synchronized Entry get(String key) {
CacheHeader entry = mEntries.get(key);
// if the entry does not exist, return.
if (entry == null) {
return null;
}
File file = getFileForKey(key);
CountingInputStream cis = null;
try {
cis = new CountingInputStream(new BufferedInputStream(new FileInputStream(file)));
CacheHeader.readHeader(cis); // eat header
byte[] data = streamToBytes(cis, (int) (file.length() - cis.bytesRead));
return entry.toCacheEntry(data);
} catch (IOException e) {
//todo add queue markers
JusLog.log(file.getAbsolutePath() + ": " + e.toString());
remove(key);
return null;
} catch (NegativeArraySizeException e) {
JusLog.log(file.getAbsolutePath() + ": " + e.toString());
remove(key);
return null;
} finally {
if (cis != null) {
try {
cis.close();
} catch (IOException ioe) {
return null;
}
}
}
} | [
"@",
"Override",
"public",
"synchronized",
"Entry",
"get",
"(",
"String",
"key",
")",
"{",
"CacheHeader",
"entry",
"=",
"mEntries",
".",
"get",
"(",
"key",
")",
";",
"// if the entry does not exist, return.",
"if",
"(",
"entry",
"==",
"null",
")",
"{",
"retu... | Returns the cache entry with the specified key if it exists, null otherwise. | [
"Returns",
"the",
"cache",
"entry",
"with",
"the",
"specified",
"key",
"if",
"it",
"exists",
"null",
"otherwise",
"."
] | 8a37a21b41f897d68eaeaab07368ec22a1e5a60e | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/jus-java/src/main/java/io/apptik/comm/jus/toolbox/DiskBasedCache.java#L124-L157 | train |
apptik/jus | jus-java/src/main/java/io/apptik/comm/jus/toolbox/DiskBasedCache.java | DiskBasedCache.initialize | @Override
public synchronized void initialize() {
if (!mRootDirectory.exists()) {
if (!mRootDirectory.mkdirs()) {
//silently ignoring no cache is not good so we throw and let the user decide
// what
// to do
throw new IllegalStateException("Unable to create cache dir: " + mRootDirectory
.getAbsolutePath());
}
//we have an empty cache so we just return
return;
}
File[] files = mRootDirectory.listFiles();
if (files == null) {
return;
}
for (File file : files) {
BufferedInputStream fis = null;
try {
fis = new BufferedInputStream(new FileInputStream(file));
CacheHeader entry = CacheHeader.readHeader(fis);
entry.size = file.length();
putEntry(entry.key, entry);
} catch (IOException e) {
if (file != null) {
file.delete();
}
} finally {
try {
if (fis != null) {
fis.close();
}
} catch (IOException ignored) {
}
}
}
} | java | @Override
public synchronized void initialize() {
if (!mRootDirectory.exists()) {
if (!mRootDirectory.mkdirs()) {
//silently ignoring no cache is not good so we throw and let the user decide
// what
// to do
throw new IllegalStateException("Unable to create cache dir: " + mRootDirectory
.getAbsolutePath());
}
//we have an empty cache so we just return
return;
}
File[] files = mRootDirectory.listFiles();
if (files == null) {
return;
}
for (File file : files) {
BufferedInputStream fis = null;
try {
fis = new BufferedInputStream(new FileInputStream(file));
CacheHeader entry = CacheHeader.readHeader(fis);
entry.size = file.length();
putEntry(entry.key, entry);
} catch (IOException e) {
if (file != null) {
file.delete();
}
} finally {
try {
if (fis != null) {
fis.close();
}
} catch (IOException ignored) {
}
}
}
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"initialize",
"(",
")",
"{",
"if",
"(",
"!",
"mRootDirectory",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"mRootDirectory",
".",
"mkdirs",
"(",
")",
")",
"{",
"//silently ignoring no cache is not goo... | Initializes the DiskBasedCache by scanning for all files currently in the
specified root directory. Creates the root directory if necessary. | [
"Initializes",
"the",
"DiskBasedCache",
"by",
"scanning",
"for",
"all",
"files",
"currently",
"in",
"the",
"specified",
"root",
"directory",
".",
"Creates",
"the",
"root",
"directory",
"if",
"necessary",
"."
] | 8a37a21b41f897d68eaeaab07368ec22a1e5a60e | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/jus-java/src/main/java/io/apptik/comm/jus/toolbox/DiskBasedCache.java#L163-L201 | train |
apptik/jus | jus-java/src/main/java/io/apptik/comm/jus/http/MultipartBuilder.java | MultipartBuilder.addPart | public MultipartBuilder addPart(NetworkRequest part) {
if (part == null) {
throw new NullPointerException("part == null");
}
parts.add(part);
return this;
} | java | public MultipartBuilder addPart(NetworkRequest part) {
if (part == null) {
throw new NullPointerException("part == null");
}
parts.add(part);
return this;
} | [
"public",
"MultipartBuilder",
"addPart",
"(",
"NetworkRequest",
"part",
")",
"{",
"if",
"(",
"part",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"part == null\"",
")",
";",
"}",
"parts",
".",
"add",
"(",
"part",
")",
";",
"return... | Add a part to the body. | [
"Add",
"a",
"part",
"to",
"the",
"body",
"."
] | 8a37a21b41f897d68eaeaab07368ec22a1e5a60e | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/jus-java/src/main/java/io/apptik/comm/jus/http/MultipartBuilder.java#L116-L122 | train |
apptik/jus | jus-java/src/main/java/io/apptik/comm/jus/http/MultipartBuilder.java | MultipartBuilder.build | public NetworkRequest build() {
if (parts.isEmpty()) {
throw new IllegalStateException("Multipart body must have at least one part.");
}
MultipartRequest mrb = new MultipartRequest(type, boundary, parts);
Buffer bb = new Buffer();
try {
mrb.writeOrCountBytes(bb, false);
} catch (IOException e) {
e.printStackTrace();
}
return new NetworkRequest.Builder()
.setContentType(mrb.contentType())
.setBody(bb.readByteArray())
.build();
} | java | public NetworkRequest build() {
if (parts.isEmpty()) {
throw new IllegalStateException("Multipart body must have at least one part.");
}
MultipartRequest mrb = new MultipartRequest(type, boundary, parts);
Buffer bb = new Buffer();
try {
mrb.writeOrCountBytes(bb, false);
} catch (IOException e) {
e.printStackTrace();
}
return new NetworkRequest.Builder()
.setContentType(mrb.contentType())
.setBody(bb.readByteArray())
.build();
} | [
"public",
"NetworkRequest",
"build",
"(",
")",
"{",
"if",
"(",
"parts",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Multipart body must have at least one part.\"",
")",
";",
"}",
"MultipartRequest",
"mrb",
"=",
"new",
"Mu... | Assemble the specified parts into a request body. | [
"Assemble",
"the",
"specified",
"parts",
"into",
"a",
"request",
"body",
"."
] | 8a37a21b41f897d68eaeaab07368ec22a1e5a60e | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/jus-java/src/main/java/io/apptik/comm/jus/http/MultipartBuilder.java#L186-L201 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/XsdAnnotationEmitter.java | XsdAnnotationEmitter.addNamespaceContext | protected void addNamespaceContext() {
NamespaceMap prefixmap = new NamespaceMap();
NamespacePrefixList npl = getXsd().getNamespaceContext();
if (npl == null) {
/* We get an NPE if we don't add this. */
prefixmap.add("", XMLConstants.W3C_XML_SCHEMA_NS_URI);
} else {
for (int i = 0; i < npl.getDeclaredPrefixes().length; i++) {
prefixmap.add(npl.getDeclaredPrefixes()[i],
npl.getNamespaceURI(npl.getDeclaredPrefixes()[i]));
}
}
prefixmap.add(getCOXBNamespacePrefix(), getCOXBNamespace());
getXsd().setNamespaceContext(prefixmap);
} | java | protected void addNamespaceContext() {
NamespaceMap prefixmap = new NamespaceMap();
NamespacePrefixList npl = getXsd().getNamespaceContext();
if (npl == null) {
/* We get an NPE if we don't add this. */
prefixmap.add("", XMLConstants.W3C_XML_SCHEMA_NS_URI);
} else {
for (int i = 0; i < npl.getDeclaredPrefixes().length; i++) {
prefixmap.add(npl.getDeclaredPrefixes()[i],
npl.getNamespaceURI(npl.getDeclaredPrefixes()[i]));
}
}
prefixmap.add(getCOXBNamespacePrefix(), getCOXBNamespace());
getXsd().setNamespaceContext(prefixmap);
} | [
"protected",
"void",
"addNamespaceContext",
"(",
")",
"{",
"NamespaceMap",
"prefixmap",
"=",
"new",
"NamespaceMap",
"(",
")",
";",
"NamespacePrefixList",
"npl",
"=",
"getXsd",
"(",
")",
".",
"getNamespaceContext",
"(",
")",
";",
"if",
"(",
"npl",
"==",
"null... | Adds the COXB namespace and associated prefixes to the XML schema. | [
"Adds",
"the",
"COXB",
"namespace",
"and",
"associated",
"prefixes",
"to",
"the",
"XML",
"schema",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/XsdAnnotationEmitter.java#L217-L232 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/antlr/RecognizerErrorHandler.java | RecognizerErrorHandler.getErrorMessage | public static String getErrorMessage(
final Logger log,
final BaseRecognizer recognizer,
final RecognitionException e,
final String superMessage,
final String[] tokenNames) {
if (log.isDebugEnabled()) {
List < ? > stack = BaseRecognizer.getRuleInvocationStack(
e, recognizer.getClass().getSuperclass().getName());
String debugMsg = recognizer.getErrorHeader(e)
+ " " + e.getClass().getSimpleName()
+ ": " + superMessage
+ ":";
if (e instanceof NoViableAltException) {
NoViableAltException nvae = (NoViableAltException) e;
debugMsg += " (decision=" + nvae.decisionNumber
+ " state=" + nvae.stateNumber + ")"
+ " decision=<<" + nvae.grammarDecisionDescription + ">>";
} else if (e instanceof UnwantedTokenException) {
UnwantedTokenException ute = (UnwantedTokenException) e;
debugMsg += " (unexpected token=" + toString(ute.getUnexpectedToken(), tokenNames) + ")";
} else if (e instanceof EarlyExitException) {
EarlyExitException eea = (EarlyExitException) e;
debugMsg += " (decision=" + eea.decisionNumber + ")";
}
debugMsg += " ruleStack=" + stack.toString();
log.debug(debugMsg);
}
return makeUserMsg(e, superMessage);
} | java | public static String getErrorMessage(
final Logger log,
final BaseRecognizer recognizer,
final RecognitionException e,
final String superMessage,
final String[] tokenNames) {
if (log.isDebugEnabled()) {
List < ? > stack = BaseRecognizer.getRuleInvocationStack(
e, recognizer.getClass().getSuperclass().getName());
String debugMsg = recognizer.getErrorHeader(e)
+ " " + e.getClass().getSimpleName()
+ ": " + superMessage
+ ":";
if (e instanceof NoViableAltException) {
NoViableAltException nvae = (NoViableAltException) e;
debugMsg += " (decision=" + nvae.decisionNumber
+ " state=" + nvae.stateNumber + ")"
+ " decision=<<" + nvae.grammarDecisionDescription + ">>";
} else if (e instanceof UnwantedTokenException) {
UnwantedTokenException ute = (UnwantedTokenException) e;
debugMsg += " (unexpected token=" + toString(ute.getUnexpectedToken(), tokenNames) + ")";
} else if (e instanceof EarlyExitException) {
EarlyExitException eea = (EarlyExitException) e;
debugMsg += " (decision=" + eea.decisionNumber + ")";
}
debugMsg += " ruleStack=" + stack.toString();
log.debug(debugMsg);
}
return makeUserMsg(e, superMessage);
} | [
"public",
"static",
"String",
"getErrorMessage",
"(",
"final",
"Logger",
"log",
",",
"final",
"BaseRecognizer",
"recognizer",
",",
"final",
"RecognitionException",
"e",
",",
"final",
"String",
"superMessage",
",",
"final",
"String",
"[",
"]",
"tokenNames",
")",
... | Format an error message as expected by ANTLR. It is basically the
same error message that ANTL BaseRecognizer generates with some
additional data.
Also used to log debugging information.
@param log the logger to use at debug time
@param recognizer the lexer or parser who generated the error
@param e the exception that occured
@param superMessage the error message that the super class generated
@param tokenNames list of token names
@return a formatted error message | [
"Format",
"an",
"error",
"message",
"as",
"expected",
"by",
"ANTLR",
".",
"It",
"is",
"basically",
"the",
"same",
"error",
"message",
"that",
"ANTL",
"BaseRecognizer",
"generates",
"with",
"some",
"additional",
"data",
".",
"Also",
"used",
"to",
"log",
"debu... | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/antlr/RecognizerErrorHandler.java#L51-L82 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/antlr/RecognizerErrorHandler.java | RecognizerErrorHandler.makeUserMsg | public static String makeUserMsg(final RecognitionException e, final String msg) {
if (e instanceof NoViableAltException) {
return msg.replace("no viable alternative at", "unrecognized");
} else if (e instanceof UnwantedTokenException) {
return msg.replace("extraneous input", "unexpected token");
} else if (e instanceof MismatchedTokenException) {
if (msg.contains("mismatched input '<EOF>'")) {
return msg.replace("mismatched input '<EOF>' expecting", "reached end of file looking for");
} else {
return msg.replace("mismatched input", "unexpected token");
}
} else if (e instanceof EarlyExitException) {
return msg.replace("required (...)+ loop did not match anything", "required tokens not found");
} else if (e instanceof FailedPredicateException) {
if (msg.contains("picture_string failed predicate: {Unbalanced parentheses}")) {
return "Unbalanced parentheses in picture string";
}
if (msg.contains("PICTURE_PART failed predicate: {Contains invalid picture symbols}")) {
return "Picture string contains invalid symbols";
}
if (msg.contains("PICTURE_PART failed predicate: {Syntax error in last picture clause}")) {
return "Syntax error in last picture clause";
}
if (msg.contains("DATA_NAME failed predicate: {Syntax error in last clause}")) {
return "Syntax error in last COBOL clause";
}
}
return msg;
} | java | public static String makeUserMsg(final RecognitionException e, final String msg) {
if (e instanceof NoViableAltException) {
return msg.replace("no viable alternative at", "unrecognized");
} else if (e instanceof UnwantedTokenException) {
return msg.replace("extraneous input", "unexpected token");
} else if (e instanceof MismatchedTokenException) {
if (msg.contains("mismatched input '<EOF>'")) {
return msg.replace("mismatched input '<EOF>' expecting", "reached end of file looking for");
} else {
return msg.replace("mismatched input", "unexpected token");
}
} else if (e instanceof EarlyExitException) {
return msg.replace("required (...)+ loop did not match anything", "required tokens not found");
} else if (e instanceof FailedPredicateException) {
if (msg.contains("picture_string failed predicate: {Unbalanced parentheses}")) {
return "Unbalanced parentheses in picture string";
}
if (msg.contains("PICTURE_PART failed predicate: {Contains invalid picture symbols}")) {
return "Picture string contains invalid symbols";
}
if (msg.contains("PICTURE_PART failed predicate: {Syntax error in last picture clause}")) {
return "Syntax error in last picture clause";
}
if (msg.contains("DATA_NAME failed predicate: {Syntax error in last clause}")) {
return "Syntax error in last COBOL clause";
}
}
return msg;
} | [
"public",
"static",
"String",
"makeUserMsg",
"(",
"final",
"RecognitionException",
"e",
",",
"final",
"String",
"msg",
")",
"{",
"if",
"(",
"e",
"instanceof",
"NoViableAltException",
")",
"{",
"return",
"msg",
".",
"replace",
"(",
"\"no viable alternative at\"",
... | Simplify error message text for end users.
@param e exception that occurred
@param msg as formatted by ANTLR
@return a more readable error message | [
"Simplify",
"error",
"message",
"text",
"for",
"end",
"users",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/antlr/RecognizerErrorHandler.java#L90-L118 | train |
jingwei/krati | krati-main/src/main/java/krati/store/IndexedDataStore.java | IndexedDataStore.initIndexPersistableListener | protected void initIndexPersistableListener() {
_index.setPersistableListener(new PersistableListener() {
@Override
public void beforePersist() {
try {
PersistableListener l = _listener;
if(l != null) l.beforePersist();
} catch (Exception e) {
_logger.error("failed on calling beforePersist", e);
}
try {
_bytesDB.persist();
} catch (Exception e) {
_logger.error("failed on calling beforePersist", e);
}
}
@Override
public void afterPersist() {
try {
PersistableListener l = _listener;
if(l != null) l.afterPersist();
} catch(Exception e) {
_logger.error("failed on calling afterPersist", e);
}
}
});
} | java | protected void initIndexPersistableListener() {
_index.setPersistableListener(new PersistableListener() {
@Override
public void beforePersist() {
try {
PersistableListener l = _listener;
if(l != null) l.beforePersist();
} catch (Exception e) {
_logger.error("failed on calling beforePersist", e);
}
try {
_bytesDB.persist();
} catch (Exception e) {
_logger.error("failed on calling beforePersist", e);
}
}
@Override
public void afterPersist() {
try {
PersistableListener l = _listener;
if(l != null) l.afterPersist();
} catch(Exception e) {
_logger.error("failed on calling afterPersist", e);
}
}
});
} | [
"protected",
"void",
"initIndexPersistableListener",
"(",
")",
"{",
"_index",
".",
"setPersistableListener",
"(",
"new",
"PersistableListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"beforePersist",
"(",
")",
"{",
"try",
"{",
"PersistableListener",
"l"... | Initialize the Index persistable listener. | [
"Initialize",
"the",
"Index",
"persistable",
"listener",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/store/IndexedDataStore.java#L249-L277 | train |
jingwei/krati | krati-main/src/examples/java/krati/examples/KratiDataPartition.java | KratiDataPartition.populate | public void populate() throws Exception {
for (int i = 0, cnt = _partition.getIdCount(); i < cnt; i++) {
int memberId = _partition.getIdStart() + i;
_partition.set(memberId, createDataForMember(memberId), System.nanoTime());
}
_partition.sync();
} | java | public void populate() throws Exception {
for (int i = 0, cnt = _partition.getIdCount(); i < cnt; i++) {
int memberId = _partition.getIdStart() + i;
_partition.set(memberId, createDataForMember(memberId), System.nanoTime());
}
_partition.sync();
} | [
"public",
"void",
"populate",
"(",
")",
"throws",
"Exception",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"cnt",
"=",
"_partition",
".",
"getIdCount",
"(",
")",
";",
"i",
"<",
"cnt",
";",
"i",
"++",
")",
"{",
"int",
"memberId",
"=",
"_partition",
... | Populates the underlying data partition.
@throws Exception | [
"Populates",
"the",
"underlying",
"data",
"partition",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/examples/java/krati/examples/KratiDataPartition.java#L74-L80 | train |
jingwei/krati | krati-main/src/examples/java/krati/examples/KratiDataPartition.java | KratiDataPartition.doRandomReads | public void doRandomReads(int readCnt) {
Random rand = new Random();
int idStart = _partition.getIdStart();
int idCount = _partition.getIdCount();
for (int i = 0; i < readCnt; i++) {
int memberId = idStart + rand.nextInt(idCount);
System.out.printf("MemberId=%-10d MemberData=%s%n", memberId, new String(_partition.get(memberId)));
}
} | java | public void doRandomReads(int readCnt) {
Random rand = new Random();
int idStart = _partition.getIdStart();
int idCount = _partition.getIdCount();
for (int i = 0; i < readCnt; i++) {
int memberId = idStart + rand.nextInt(idCount);
System.out.printf("MemberId=%-10d MemberData=%s%n", memberId, new String(_partition.get(memberId)));
}
} | [
"public",
"void",
"doRandomReads",
"(",
"int",
"readCnt",
")",
"{",
"Random",
"rand",
"=",
"new",
"Random",
"(",
")",
";",
"int",
"idStart",
"=",
"_partition",
".",
"getIdStart",
"(",
")",
";",
"int",
"idCount",
"=",
"_partition",
".",
"getIdCount",
"(",... | Perform a number of random reads from the underlying data partition.
@param readCnt the number of reads | [
"Perform",
"a",
"number",
"of",
"random",
"reads",
"from",
"the",
"underlying",
"data",
"partition",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/examples/java/krati/examples/KratiDataPartition.java#L87-L95 | train |
jingwei/krati | krati-main/src/examples/java/krati/examples/KratiDataPartition.java | KratiDataPartition.main | public static void main(String[] args) {
try {
// Parse arguments: homeDir idStart idCount
File homeDir = new File(args[0]);
int idStart = Integer.parseInt(args[1]);
int idCount = Integer.parseInt(args[2]);
// Create an instance of KratiDataPartition
KratiDataPartition p = new KratiDataPartition(homeDir, idStart, idCount);
// Populate data partition
p.populate();
// Perform some random reads from data partition.
p.doRandomReads(10);
// Close data partition
p.close();
} catch(Exception e) {
e.printStackTrace();
}
} | java | public static void main(String[] args) {
try {
// Parse arguments: homeDir idStart idCount
File homeDir = new File(args[0]);
int idStart = Integer.parseInt(args[1]);
int idCount = Integer.parseInt(args[2]);
// Create an instance of KratiDataPartition
KratiDataPartition p = new KratiDataPartition(homeDir, idStart, idCount);
// Populate data partition
p.populate();
// Perform some random reads from data partition.
p.doRandomReads(10);
// Close data partition
p.close();
} catch(Exception e) {
e.printStackTrace();
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"try",
"{",
"// Parse arguments: homeDir idStart idCount",
"File",
"homeDir",
"=",
"new",
"File",
"(",
"args",
"[",
"0",
"]",
")",
";",
"int",
"idStart",
"=",
"Integer",
".",
... | java -Xmx4G krati.examples.KratiDataPartition homeDir idStart idCount | [
"java",
"-",
"Xmx4G",
"krati",
".",
"examples",
".",
"KratiDataPartition",
"homeDir",
"idStart",
"idCount"
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/examples/java/krati/examples/KratiDataPartition.java#L128-L149 | train |
jingwei/krati | krati-main/src/retention/java/krati/retention/clock/SourceWaterMarksClock.java | SourceWaterMarksClock.updateHWMark | @Override
public synchronized Clock updateHWMark(String source, long hwm) {
_sourceWaterMarks.saveHWMark(source, hwm);
return current();
} | java | @Override
public synchronized Clock updateHWMark(String source, long hwm) {
_sourceWaterMarks.saveHWMark(source, hwm);
return current();
} | [
"@",
"Override",
"public",
"synchronized",
"Clock",
"updateHWMark",
"(",
"String",
"source",
",",
"long",
"hwm",
")",
"{",
"_sourceWaterMarks",
".",
"saveHWMark",
"(",
"source",
",",
"hwm",
")",
";",
"return",
"current",
"(",
")",
";",
"}"
] | Save the high water mark of a given source.
@param source
@param hwm | [
"Save",
"the",
"high",
"water",
"mark",
"of",
"a",
"given",
"source",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/retention/java/krati/retention/clock/SourceWaterMarksClock.java#L134-L138 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PDQConsumerAuditor.java | PDQConsumerAuditor.getAuditor | public static PDQConsumerAuditor getAuditor()
{
AuditorModuleContext ctx = AuditorModuleContext.getContext();
return (PDQConsumerAuditor)ctx.getAuditor(PDQConsumerAuditor.class);
} | java | public static PDQConsumerAuditor getAuditor()
{
AuditorModuleContext ctx = AuditorModuleContext.getContext();
return (PDQConsumerAuditor)ctx.getAuditor(PDQConsumerAuditor.class);
} | [
"public",
"static",
"PDQConsumerAuditor",
"getAuditor",
"(",
")",
"{",
"AuditorModuleContext",
"ctx",
"=",
"AuditorModuleContext",
".",
"getContext",
"(",
")",
";",
"return",
"(",
"PDQConsumerAuditor",
")",
"ctx",
".",
"getAuditor",
"(",
"PDQConsumerAuditor",
".",
... | Get an instance of the PDQ Consumer Auditor from the
global context
@return PDQ Consumer Auditor instance | [
"Get",
"an",
"instance",
"of",
"the",
"PDQ",
"Consumer",
"Auditor",
"from",
"the",
"global",
"context"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PDQConsumerAuditor.java#L43-L47 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PDQConsumerAuditor.java | PDQConsumerAuditor.auditPDQQueryEvent | public void auditPDQQueryEvent(RFC3881EventOutcomeCodes eventOutcome,
String pixManagerUri, String receivingFacility, String receivingApp,
String sendingFacility, String sendingApp,
String hl7MessageControlId, String hl7QueryParameters,
String[] patientIds)
{
if (!isAuditorEnabled()) {
return;
}
auditQueryEvent(true,
new IHETransactionEventTypeCodes.PatientDemographicsQuery(), eventOutcome,
sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(),
receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false),
getHumanRequestor(),
hl7MessageControlId, hl7QueryParameters,
patientIds, null, null);
} | java | public void auditPDQQueryEvent(RFC3881EventOutcomeCodes eventOutcome,
String pixManagerUri, String receivingFacility, String receivingApp,
String sendingFacility, String sendingApp,
String hl7MessageControlId, String hl7QueryParameters,
String[] patientIds)
{
if (!isAuditorEnabled()) {
return;
}
auditQueryEvent(true,
new IHETransactionEventTypeCodes.PatientDemographicsQuery(), eventOutcome,
sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(),
receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false),
getHumanRequestor(),
hl7MessageControlId, hl7QueryParameters,
patientIds, null, null);
} | [
"public",
"void",
"auditPDQQueryEvent",
"(",
"RFC3881EventOutcomeCodes",
"eventOutcome",
",",
"String",
"pixManagerUri",
",",
"String",
"receivingFacility",
",",
"String",
"receivingApp",
",",
"String",
"sendingFacility",
",",
"String",
"sendingApp",
",",
"String",
"hl7... | Audits an ITI-21 Patient Demographics Query event for
Patient Demographics Consumer actors.
@param eventOutcome The event outcome indicator
@param pixManagerUri The URI of the PIX Manager being accessed
@param receivingFacility The HL7 receiving facility
@param receivingApp The HL7 receiving application
@param sendingFacility The HL7 sending facility
@param sendingApp The HL7 sending application
@param hl7MessageControlId The HL7 message control id from the MSH segment
@param hl7QueryParameters The HL7 query parameters from the QPD segment
@param patientIds List of patient IDs that were seen in this transaction | [
"Audits",
"an",
"ITI",
"-",
"21",
"Patient",
"Demographics",
"Query",
"event",
"for",
"Patient",
"Demographics",
"Consumer",
"actors",
"."
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PDQConsumerAuditor.java#L63-L79 | train |
oehf/ipf-oht-atna | nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomainManager.java | SecurityDomainManager.formatKey | public String formatKey(URI uri) throws URISyntaxException
{
if (uri == null) {
throw new URISyntaxException("","URI specified is null");
}
return formatKey(uri.getHost(), uri.getPort());
} | java | public String formatKey(URI uri) throws URISyntaxException
{
if (uri == null) {
throw new URISyntaxException("","URI specified is null");
}
return formatKey(uri.getHost(), uri.getPort());
} | [
"public",
"String",
"formatKey",
"(",
"URI",
"uri",
")",
"throws",
"URISyntaxException",
"{",
"if",
"(",
"uri",
"==",
"null",
")",
"{",
"throw",
"new",
"URISyntaxException",
"(",
"\"\"",
",",
"\"URI specified is null\"",
")",
";",
"}",
"return",
"formatKey",
... | Converts a well-formed URI containing a hostname and port into
string which allows for lookups in the Security Domain table
@param uri URI to convert
@return A string with "host:port" concatenated
@throws URISyntaxException | [
"Converts",
"a",
"well",
"-",
"formed",
"URI",
"containing",
"a",
"hostname",
"and",
"port",
"into",
"string",
"which",
"allows",
"for",
"lookups",
"in",
"the",
"Security",
"Domain",
"table"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomainManager.java#L240-L246 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArray.java | SimpleDataArray.submitSegmentIndexBuffer | protected void submitSegmentIndexBuffer() {
if(_sibEnabled && !_sib.isDirty()) {
_sib.setSegmentId(_segment.getSegmentId());
_sib.setSegmentLastForcedTime(_segment.getLastForcedTime());
_segmentManager.submit(_sib);
} else {
_segmentManager.remove(_sib);
}
} | java | protected void submitSegmentIndexBuffer() {
if(_sibEnabled && !_sib.isDirty()) {
_sib.setSegmentId(_segment.getSegmentId());
_sib.setSegmentLastForcedTime(_segment.getLastForcedTime());
_segmentManager.submit(_sib);
} else {
_segmentManager.remove(_sib);
}
} | [
"protected",
"void",
"submitSegmentIndexBuffer",
"(",
")",
"{",
"if",
"(",
"_sibEnabled",
"&&",
"!",
"_sib",
".",
"isDirty",
"(",
")",
")",
"{",
"_sib",
".",
"setSegmentId",
"(",
"_segment",
".",
"getSegmentId",
"(",
")",
")",
";",
"_sib",
".",
"setSegme... | Submit current segment index buffer for asynchronous handling. | [
"Submit",
"current",
"segment",
"index",
"buffer",
"for",
"asynchronous",
"handling",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArray.java#L287-L295 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArray.java | SimpleDataArray.init | protected void init() {
try {
// Initialize the current working segment
_segment = _segmentManager.nextSegment();
// Segment index buffer is enabled by default!
_sib = _segmentManager.openSegmentIndexBuffer(_segment.getSegmentId());
if(!_sibEnabled) _sib.markAsDirty();
_log.info("Segment " + _segment.getSegmentId() + " online: " + _segment.getStatus());
} catch(IOException ioe) {
_log.error(ioe.getMessage(), ioe);
throw new SegmentException("Instantiation failed due to " + ioe.getMessage());
}
} | java | protected void init() {
try {
// Initialize the current working segment
_segment = _segmentManager.nextSegment();
// Segment index buffer is enabled by default!
_sib = _segmentManager.openSegmentIndexBuffer(_segment.getSegmentId());
if(!_sibEnabled) _sib.markAsDirty();
_log.info("Segment " + _segment.getSegmentId() + " online: " + _segment.getStatus());
} catch(IOException ioe) {
_log.error(ioe.getMessage(), ioe);
throw new SegmentException("Instantiation failed due to " + ioe.getMessage());
}
} | [
"protected",
"void",
"init",
"(",
")",
"{",
"try",
"{",
"// Initialize the current working segment",
"_segment",
"=",
"_segmentManager",
".",
"nextSegment",
"(",
")",
";",
"// Segment index buffer is enabled by default!",
"_sib",
"=",
"_segmentManager",
".",
"openSegmentI... | Initialize this SimpleDataArray after it is instantiated. | [
"Initialize",
"this",
"SimpleDataArray",
"after",
"it",
"is",
"instantiated",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArray.java#L300-L314 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArray.java | SimpleDataArray.decrOriginalSegmentLoad | protected void decrOriginalSegmentLoad(int index) {
try {
long address = getAddress(index);
int segPos = _addressFormat.getOffset(address);
int segInd = _addressFormat.getSegment(address);
int length = _addressFormat.getDataSize(address);
if (segPos >= Segment.dataStartPosition) {
// get data segment
Segment seg = _segmentManager.getSegment(segInd);
// read data length
if(seg != null) seg.decrLoadSize(4 + ((length == 0) ? seg.readInt(segPos) : length));
}
}
catch(IOException e1) {}
catch(IndexOutOfBoundsException e2) {}
} | java | protected void decrOriginalSegmentLoad(int index) {
try {
long address = getAddress(index);
int segPos = _addressFormat.getOffset(address);
int segInd = _addressFormat.getSegment(address);
int length = _addressFormat.getDataSize(address);
if (segPos >= Segment.dataStartPosition) {
// get data segment
Segment seg = _segmentManager.getSegment(segInd);
// read data length
if(seg != null) seg.decrLoadSize(4 + ((length == 0) ? seg.readInt(segPos) : length));
}
}
catch(IOException e1) {}
catch(IndexOutOfBoundsException e2) {}
} | [
"protected",
"void",
"decrOriginalSegmentLoad",
"(",
"int",
"index",
")",
"{",
"try",
"{",
"long",
"address",
"=",
"getAddress",
"(",
"index",
")",
";",
"int",
"segPos",
"=",
"_addressFormat",
".",
"getOffset",
"(",
"address",
")",
";",
"int",
"segInd",
"=... | Decrease the load factor of a Segment based on the specified array index.
@param index - the array index. | [
"Decrease",
"the",
"load",
"factor",
"of",
"a",
"Segment",
"based",
"on",
"the",
"specified",
"array",
"index",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArray.java#L393-L410 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArray.java | SimpleDataArray.get | @Override
public byte[] get(int index) {
rangeCheck(index);
try {
long address = getAddress(index);
int segPos = _addressFormat.getOffset(address);
int segInd = _addressFormat.getSegment(address);
// no data found
if(segPos < Segment.dataStartPosition) return null;
// get data segment
Segment seg = _segmentManager.getSegment(segInd);
if(seg == null) return null;
// read data length
int size = _addressFormat.getDataSize(address);
int len = (size == 0) ? seg.readInt(segPos) : size;
// read data into byte array
byte[] data = new byte[len];
if (len > 0) {
seg.read(segPos + 4, data);
}
return data;
} catch(Exception e) {
_log.warn(e.getMessage());
return null;
}
} | java | @Override
public byte[] get(int index) {
rangeCheck(index);
try {
long address = getAddress(index);
int segPos = _addressFormat.getOffset(address);
int segInd = _addressFormat.getSegment(address);
// no data found
if(segPos < Segment.dataStartPosition) return null;
// get data segment
Segment seg = _segmentManager.getSegment(segInd);
if(seg == null) return null;
// read data length
int size = _addressFormat.getDataSize(address);
int len = (size == 0) ? seg.readInt(segPos) : size;
// read data into byte array
byte[] data = new byte[len];
if (len > 0) {
seg.read(segPos + 4, data);
}
return data;
} catch(Exception e) {
_log.warn(e.getMessage());
return null;
}
} | [
"@",
"Override",
"public",
"byte",
"[",
"]",
"get",
"(",
"int",
"index",
")",
"{",
"rangeCheck",
"(",
"index",
")",
";",
"try",
"{",
"long",
"address",
"=",
"getAddress",
"(",
"index",
")",
";",
"int",
"segPos",
"=",
"_addressFormat",
".",
"getOffset",... | Gets data at a given index.
@param index the array index
@return the data at a given index.
@throws ArrayIndexOutOfBoundsException if the index is out of range. | [
"Gets",
"data",
"at",
"a",
"given",
"index",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArray.java#L479-L510 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArray.java | SimpleDataArray.read | public int read(int index, byte[] dst) {
rangeCheck(index);
try {
long address = getAddress(index);
int segPos = _addressFormat.getOffset(address);
int segInd = _addressFormat.getSegment(address);
// no data found
if(segPos < Segment.dataStartPosition) return -1;
// get data segment
Segment seg = _segmentManager.getSegment(segInd);
if(seg == null) return -1;
// read data length
int size = _addressFormat.getDataSize(address);
int len = (size == 0) ? seg.readInt(segPos) : size;
// read data into byte array
if (len > 0) {
len = Math.min(len, dst.length);
seg.read(segPos + 4, dst, 0, len);
}
return len;
} catch(Exception e) {
_log.warn(e.getMessage());
return -1;
}
} | java | public int read(int index, byte[] dst) {
rangeCheck(index);
try {
long address = getAddress(index);
int segPos = _addressFormat.getOffset(address);
int segInd = _addressFormat.getSegment(address);
// no data found
if(segPos < Segment.dataStartPosition) return -1;
// get data segment
Segment seg = _segmentManager.getSegment(segInd);
if(seg == null) return -1;
// read data length
int size = _addressFormat.getDataSize(address);
int len = (size == 0) ? seg.readInt(segPos) : size;
// read data into byte array
if (len > 0) {
len = Math.min(len, dst.length);
seg.read(segPos + 4, dst, 0, len);
}
return len;
} catch(Exception e) {
_log.warn(e.getMessage());
return -1;
}
} | [
"public",
"int",
"read",
"(",
"int",
"index",
",",
"byte",
"[",
"]",
"dst",
")",
"{",
"rangeCheck",
"(",
"index",
")",
";",
"try",
"{",
"long",
"address",
"=",
"getAddress",
"(",
"index",
")",
";",
"int",
"segPos",
"=",
"_addressFormat",
".",
"getOff... | Reads data bytes at an index into a byte array.
This method does a full read of data bytes only if the destination byte
array has enough capacity to store all the bytes from the specified index.
Otherwise, a partial read is done to fill in the destination byte array.
@param index the array index
@param dst the byte array to fill in
@return the total number of bytes read if data is available at the given index.
Otherwise, <code>-1</code>. | [
"Reads",
"data",
"bytes",
"at",
"an",
"index",
"into",
"a",
"byte",
"array",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArray.java#L580-L610 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArray.java | SimpleDataArray.transferTo | @Override
public int transferTo(int index, WritableByteChannel channel) {
rangeCheck(index);
try {
long address = getAddress(index);
int segPos = _addressFormat.getOffset(address);
int segInd = _addressFormat.getSegment(address);
// no data found
if(segPos < Segment.dataStartPosition) return -1;
// get data segment
Segment seg = _segmentManager.getSegment(segInd);
if(seg == null) return -1;
// read data length
int size = _addressFormat.getDataSize(address);
int len = (size == 0) ? seg.readInt(segPos) : size;
// transfer data to a writable channel
if (len > 0) {
seg.transferTo(segPos + 4, len, channel);
}
return len;
} catch(Exception e) {
return -1;
}
} | java | @Override
public int transferTo(int index, WritableByteChannel channel) {
rangeCheck(index);
try {
long address = getAddress(index);
int segPos = _addressFormat.getOffset(address);
int segInd = _addressFormat.getSegment(address);
// no data found
if(segPos < Segment.dataStartPosition) return -1;
// get data segment
Segment seg = _segmentManager.getSegment(segInd);
if(seg == null) return -1;
// read data length
int size = _addressFormat.getDataSize(address);
int len = (size == 0) ? seg.readInt(segPos) : size;
// transfer data to a writable channel
if (len > 0) {
seg.transferTo(segPos + 4, len, channel);
}
return len;
} catch(Exception e) {
return -1;
}
} | [
"@",
"Override",
"public",
"int",
"transferTo",
"(",
"int",
"index",
",",
"WritableByteChannel",
"channel",
")",
"{",
"rangeCheck",
"(",
"index",
")",
";",
"try",
"{",
"long",
"address",
"=",
"getAddress",
"(",
"index",
")",
";",
"int",
"segPos",
"=",
"_... | Transfers data at a given index to a writable channel.
@param index the array index
@return the amount of bytes transferred (the length of data at the given index).
@throws ArrayIndexOutOfBoundsException if the index is out of range. | [
"Transfers",
"data",
"at",
"a",
"given",
"index",
"to",
"a",
"writable",
"channel",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArray.java#L664-L693 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArray.java | SimpleDataArray.clear | @Override
public synchronized void clear() {
if(isOpen()) {
_compactor.clear();
_addressArray.clear();
_segmentManager.clear();
this.init();
}
} | java | @Override
public synchronized void clear() {
if(isOpen()) {
_compactor.clear();
_addressArray.clear();
_segmentManager.clear();
this.init();
}
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"clear",
"(",
")",
"{",
"if",
"(",
"isOpen",
"(",
")",
")",
"{",
"_compactor",
".",
"clear",
"(",
")",
";",
"_addressArray",
".",
"clear",
"(",
")",
";",
"_segmentManager",
".",
"clear",
"(",
")",
";... | Clears all data stored in this SimpleDataArray.
This method is not effective if this SimpleDataArray is not open. | [
"Clears",
"all",
"data",
"stored",
"in",
"this",
"SimpleDataArray",
".",
"This",
"method",
"is",
"not",
"effective",
"if",
"this",
"SimpleDataArray",
"is",
"not",
"open",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArray.java#L917-L925 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArray.java | SimpleDataArray.close | @Override
public synchronized void close() throws IOException {
if (_mode == Mode.CLOSED) {
return;
}
_mode = Mode.CLOSED;
try {
// THE CALLS ORDERED.
_compactor.shutdown(); // shutdown compactor
/* Call syncInternal() to force update changes accumulated in
* the last update batch and those generated by data compaction.
*/
syncInternal(); // consume compaction batches generated during shutdown
/* Submit the current segment index buffer before closing _segmentManager
* so that the last writer segment index buffer can be flushed to disk
* when _segmentManager.close() is being invoked.
*/
submitSegmentIndexBuffer();
_compactor.clear(); // cleanup compactor internal state
_addressArray.close(); // close address array
_segmentManager.close(); // close segment manager
} catch(Exception e) {
_log.error("Failed to close", e);
throw (e instanceof IOException) ? (IOException)e : new IOException(e);
} finally {
_mode = Mode.CLOSED;
_log.info("mode=" + _mode);
}
} | java | @Override
public synchronized void close() throws IOException {
if (_mode == Mode.CLOSED) {
return;
}
_mode = Mode.CLOSED;
try {
// THE CALLS ORDERED.
_compactor.shutdown(); // shutdown compactor
/* Call syncInternal() to force update changes accumulated in
* the last update batch and those generated by data compaction.
*/
syncInternal(); // consume compaction batches generated during shutdown
/* Submit the current segment index buffer before closing _segmentManager
* so that the last writer segment index buffer can be flushed to disk
* when _segmentManager.close() is being invoked.
*/
submitSegmentIndexBuffer();
_compactor.clear(); // cleanup compactor internal state
_addressArray.close(); // close address array
_segmentManager.close(); // close segment manager
} catch(Exception e) {
_log.error("Failed to close", e);
throw (e instanceof IOException) ? (IOException)e : new IOException(e);
} finally {
_mode = Mode.CLOSED;
_log.info("mode=" + _mode);
}
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"_mode",
"==",
"Mode",
".",
"CLOSED",
")",
"{",
"return",
";",
"}",
"_mode",
"=",
"Mode",
".",
"CLOSED",
";",
"try",
"{",
"// THE CALLS ORDERED... | Close to quit from serving requests.
@throws IOException if the underlying service cannot be closed properly. | [
"Close",
"to",
"quit",
"from",
"serving",
"requests",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArray.java#L932-L965 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArray.java | SimpleDataArray.open | @Override
public synchronized void open() throws IOException {
if (_mode == Mode.OPEN) {
return;
}
try {
_addressArray.open();
_segmentManager.open();
_compactor.start();
init();
_mode = Mode.OPEN;
} catch(Exception e) {
_mode = Mode.CLOSED;
_log.error("Failed to open", e);
_compactor.shutdown();
_compactor.clear();
if (_addressArray.isOpen()) {
_addressArray.close();
}
if (_segmentManager.isOpen()) {
_segmentManager.close();
}
throw (e instanceof IOException) ? (IOException)e : new IOException(e);
} finally {
_log.info("mode=" + _mode);
}
} | java | @Override
public synchronized void open() throws IOException {
if (_mode == Mode.OPEN) {
return;
}
try {
_addressArray.open();
_segmentManager.open();
_compactor.start();
init();
_mode = Mode.OPEN;
} catch(Exception e) {
_mode = Mode.CLOSED;
_log.error("Failed to open", e);
_compactor.shutdown();
_compactor.clear();
if (_addressArray.isOpen()) {
_addressArray.close();
}
if (_segmentManager.isOpen()) {
_segmentManager.close();
}
throw (e instanceof IOException) ? (IOException)e : new IOException(e);
} finally {
_log.info("mode=" + _mode);
}
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"open",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"_mode",
"==",
"Mode",
".",
"OPEN",
")",
"{",
"return",
";",
"}",
"try",
"{",
"_addressArray",
".",
"open",
"(",
")",
";",
"_segmentManager",
... | Open to start serving requests.
@throws IOException if the underlying service cannot be opened properly. | [
"Open",
"to",
"start",
"serving",
"requests",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArray.java#L972-L1003 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArray.java | SimpleDataArray.fireBeforePersist | protected void fireBeforePersist() {
PersistableListener l = _listener;
if(l != null) {
try {
l.beforePersist();
} catch(Exception e) {
_log.error("failure on calling beforePersist", e);
}
}
} | java | protected void fireBeforePersist() {
PersistableListener l = _listener;
if(l != null) {
try {
l.beforePersist();
} catch(Exception e) {
_log.error("failure on calling beforePersist", e);
}
}
} | [
"protected",
"void",
"fireBeforePersist",
"(",
")",
"{",
"PersistableListener",
"l",
"=",
"_listener",
";",
"if",
"(",
"l",
"!=",
"null",
")",
"{",
"try",
"{",
"l",
".",
"beforePersist",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"... | Fire beforePersist events to the PersistableListener. | [
"Fire",
"beforePersist",
"events",
"to",
"the",
"PersistableListener",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArray.java#L1081-L1091 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArray.java | SimpleDataArray.fireAfterPersist | protected void fireAfterPersist() {
PersistableListener l = _listener;
if(l != null) {
try {
l.afterPersist();
} catch(Exception e) {
_log.error("failure on calling afterPersist", e);
}
}
} | java | protected void fireAfterPersist() {
PersistableListener l = _listener;
if(l != null) {
try {
l.afterPersist();
} catch(Exception e) {
_log.error("failure on calling afterPersist", e);
}
}
} | [
"protected",
"void",
"fireAfterPersist",
"(",
")",
"{",
"PersistableListener",
"l",
"=",
"_listener",
";",
"if",
"(",
"l",
"!=",
"null",
")",
"{",
"try",
"{",
"l",
".",
"afterPersist",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"_l... | Fire afterPersist events to the PersistableListener. | [
"Fire",
"afterPersist",
"events",
"to",
"the",
"PersistableListener",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArray.java#L1096-L1106 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/antlr/CobolFixedFormatSourceCleaner.java | CobolFixedFormatSourceCleaner.cleanFixedLine | public String cleanFixedLine(final String line) {
StringBuilder cleanedLine = new StringBuilder();
int length = line.length();
/* Clear sequence numbering */
for (int i = 0; i < _startColumn - 1; i++) {
cleanedLine.append(" ");
}
/* Trim anything beyond end column */
if (length > _startColumn - 1) {
String areaA = line.substring(_startColumn - 1,
(length > _endColumn) ? _endColumn : length);
cleanedLine.append(areaA);
}
return cleanedLine.toString();
} | java | public String cleanFixedLine(final String line) {
StringBuilder cleanedLine = new StringBuilder();
int length = line.length();
/* Clear sequence numbering */
for (int i = 0; i < _startColumn - 1; i++) {
cleanedLine.append(" ");
}
/* Trim anything beyond end column */
if (length > _startColumn - 1) {
String areaA = line.substring(_startColumn - 1,
(length > _endColumn) ? _endColumn : length);
cleanedLine.append(areaA);
}
return cleanedLine.toString();
} | [
"public",
"String",
"cleanFixedLine",
"(",
"final",
"String",
"line",
")",
"{",
"StringBuilder",
"cleanedLine",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"length",
"=",
"line",
".",
"length",
"(",
")",
";",
"/* Clear sequence numbering */",
"for",
"("... | Clear sequence numbers in column 1-6 and anything beyond column 72.
@param line the line of code
@return a line of code without sequence numbers | [
"Clear",
"sequence",
"numbers",
"in",
"column",
"1",
"-",
"6",
"and",
"anything",
"beyond",
"column",
"72",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/antlr/CobolFixedFormatSourceCleaner.java#L66-L84 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArrayCompactor.java | SimpleDataArrayCompactor.freeCompactedSegments | private void freeCompactedSegments() {
SegmentManager segManager = _dataArray.getSegmentManager();
if(segManager == null) return;
while(!_freeQueue.isEmpty()) {
Segment seg = _freeQueue.remove();
try {
segManager.freeSegment(seg);
} catch(Exception e) {
_log.error("failed to free Segment " + seg.getSegmentId() + ": " + seg.getStatus(), e);
}
}
} | java | private void freeCompactedSegments() {
SegmentManager segManager = _dataArray.getSegmentManager();
if(segManager == null) return;
while(!_freeQueue.isEmpty()) {
Segment seg = _freeQueue.remove();
try {
segManager.freeSegment(seg);
} catch(Exception e) {
_log.error("failed to free Segment " + seg.getSegmentId() + ": " + seg.getStatus(), e);
}
}
} | [
"private",
"void",
"freeCompactedSegments",
"(",
")",
"{",
"SegmentManager",
"segManager",
"=",
"_dataArray",
".",
"getSegmentManager",
"(",
")",
";",
"if",
"(",
"segManager",
"==",
"null",
")",
"return",
";",
"while",
"(",
"!",
"_freeQueue",
".",
"isEmpty",
... | Frees segments that were compacted successfully. | [
"Frees",
"segments",
"that",
"were",
"compacted",
"successfully",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArrayCompactor.java#L228-L240 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArrayCompactor.java | SimpleDataArrayCompactor.compact | private boolean compact() throws IOException {
try {
final boolean sibEnabled = _dataArray.isSibEnabled();
_segTarget = _dataArray.getSegmentManager().nextSegment();
for(Segment seg : _segSourceList) {
if(!_enabled) {
try {
_updateManager.endUpdate(_segTarget);
} catch (Exception e) {
_log.warn("compact abort", e);
}
_log.info("ignored Segment " + seg.getSegmentId());
continue;
}
try {
if(compact(seg, _segTarget, sibEnabled)) {
_compactedQueue.add(seg);
}
} catch(Exception e) {
if(_dataArray.isOpen()) {
_ignoredSegs.add(seg);
_log.error("failed to compact Segment " + seg.getSegmentId(), e);
}
}
}
// Mark target segment index buffer as dirty if sibEnabled is changed from true to false
if(sibEnabled && !_dataArray.isSibEnabled()) {
_dataArray.getSegmentManager().openSegmentIndexBuffer(_segTarget.getSegmentId()).markAsDirty();
}
_targetQueue.add(_segTarget);
_log.info("bytes transferred to " + _segTarget.getSegmentId() + ": " + (_segTarget.getAppendPosition() - Segment.dataStartPosition));
} catch(ConcurrentModificationException e1) {
_segSourceList.clear();
return false;
} catch(Exception e2) {
_log.warn(e2.getMessage(), e2);
return false;
}
_log.info("compact done");
return true;
} | java | private boolean compact() throws IOException {
try {
final boolean sibEnabled = _dataArray.isSibEnabled();
_segTarget = _dataArray.getSegmentManager().nextSegment();
for(Segment seg : _segSourceList) {
if(!_enabled) {
try {
_updateManager.endUpdate(_segTarget);
} catch (Exception e) {
_log.warn("compact abort", e);
}
_log.info("ignored Segment " + seg.getSegmentId());
continue;
}
try {
if(compact(seg, _segTarget, sibEnabled)) {
_compactedQueue.add(seg);
}
} catch(Exception e) {
if(_dataArray.isOpen()) {
_ignoredSegs.add(seg);
_log.error("failed to compact Segment " + seg.getSegmentId(), e);
}
}
}
// Mark target segment index buffer as dirty if sibEnabled is changed from true to false
if(sibEnabled && !_dataArray.isSibEnabled()) {
_dataArray.getSegmentManager().openSegmentIndexBuffer(_segTarget.getSegmentId()).markAsDirty();
}
_targetQueue.add(_segTarget);
_log.info("bytes transferred to " + _segTarget.getSegmentId() + ": " + (_segTarget.getAppendPosition() - Segment.dataStartPosition));
} catch(ConcurrentModificationException e1) {
_segSourceList.clear();
return false;
} catch(Exception e2) {
_log.warn(e2.getMessage(), e2);
return false;
}
_log.info("compact done");
return true;
} | [
"private",
"boolean",
"compact",
"(",
")",
"throws",
"IOException",
"{",
"try",
"{",
"final",
"boolean",
"sibEnabled",
"=",
"_dataArray",
".",
"isSibEnabled",
"(",
")",
";",
"_segTarget",
"=",
"_dataArray",
".",
"getSegmentManager",
"(",
")",
".",
"nextSegment... | Compacts a number of source fragmented Segments by moving data into a new target Segment.
@return <code>true</code> if this operation finished successfully. Otherwise, <code>false</code>.
@throws IOException if this operation can not be finished properly. | [
"Compacts",
"a",
"number",
"of",
"source",
"fragmented",
"Segments",
"by",
"moving",
"data",
"into",
"a",
"new",
"target",
"Segment",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArrayCompactor.java#L325-L370 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArrayCompactor.java | SimpleDataArrayCompactor.compact | private boolean compact(Segment segment, SegmentIndexBuffer sibSource, Segment segTarget) throws IOException {
Segment segSource = segment;
int segSourceId = segSource.getSegmentId();
int segTargetId = segTarget.getSegmentId();
Chronos c = new Chronos();
if(!segment.canReadFromBuffer() && segment.getLoadFactor() > 0.1) {
segSource = new BufferedSegment(segment, getByteBuffer((int)segment.getInitialSize()));
_log.info("buffering: " + c.tick() + " ms");
}
// Open the segment index buffer for the target segment
SegmentIndexBuffer sibTarget = _dataArray.getSegmentManager().openSegmentIndexBuffer(segTargetId);
long sizeLimit = segTarget.getInitialSize();
long bytesTransferred = 0;
boolean succ = true;
try {
AddressFormat addrFormat = _dataArray._addressFormat;
SegmentIndexBuffer.IndexOffset reuse = new SegmentIndexBuffer.IndexOffset();
for(int i = 0, cnt = sibSource.size(); i < cnt; i++) {
sibSource.get(i, reuse);
int index = reuse.getIndex();
int sibSegPos = reuse.getOffset();
long oldAddress = _dataArray.getAddress(index);
int oldSegPos = addrFormat.getOffset(oldAddress);
if(sibSegPos != oldSegPos) continue;
int oldSegInd = addrFormat.getSegment(oldAddress);
int length = addrFormat.getDataSize(oldAddress);
if (oldSegInd == segSourceId && oldSegPos >= Segment.dataStartPosition) {
if(length == 0) length = segSource.readInt(oldSegPos);
int byteCnt = 4 + length;
long newSegPos = segTarget.getAppendPosition();
long newAddress = addrFormat.composeAddress((int)newSegPos, segTargetId, length);
if(segTarget.getAppendPosition() + byteCnt >= sizeLimit) {
succ = false;
break;
}
// Transfer bytes from source to target
segSource.transferTo(oldSegPos, byteCnt, segTarget);
bytesTransferred += byteCnt;
sibTarget.add(index, (int)newSegPos);
_updateManager.addUpdate(index, byteCnt, newAddress, oldAddress, segTarget);
}
}
// Push whatever left into update queue
_updateManager.endUpdate(segTarget);
_log.info("bytes fastscanned from " + segSource.getSegmentId() + ": " + bytesTransferred + " time: " + c.tick() + " ms");
return succ;
} finally {
if(segSource.getClass() == BufferedSegment.class) {
segSource.close(false);
segSource = null;
}
}
} | java | private boolean compact(Segment segment, SegmentIndexBuffer sibSource, Segment segTarget) throws IOException {
Segment segSource = segment;
int segSourceId = segSource.getSegmentId();
int segTargetId = segTarget.getSegmentId();
Chronos c = new Chronos();
if(!segment.canReadFromBuffer() && segment.getLoadFactor() > 0.1) {
segSource = new BufferedSegment(segment, getByteBuffer((int)segment.getInitialSize()));
_log.info("buffering: " + c.tick() + " ms");
}
// Open the segment index buffer for the target segment
SegmentIndexBuffer sibTarget = _dataArray.getSegmentManager().openSegmentIndexBuffer(segTargetId);
long sizeLimit = segTarget.getInitialSize();
long bytesTransferred = 0;
boolean succ = true;
try {
AddressFormat addrFormat = _dataArray._addressFormat;
SegmentIndexBuffer.IndexOffset reuse = new SegmentIndexBuffer.IndexOffset();
for(int i = 0, cnt = sibSource.size(); i < cnt; i++) {
sibSource.get(i, reuse);
int index = reuse.getIndex();
int sibSegPos = reuse.getOffset();
long oldAddress = _dataArray.getAddress(index);
int oldSegPos = addrFormat.getOffset(oldAddress);
if(sibSegPos != oldSegPos) continue;
int oldSegInd = addrFormat.getSegment(oldAddress);
int length = addrFormat.getDataSize(oldAddress);
if (oldSegInd == segSourceId && oldSegPos >= Segment.dataStartPosition) {
if(length == 0) length = segSource.readInt(oldSegPos);
int byteCnt = 4 + length;
long newSegPos = segTarget.getAppendPosition();
long newAddress = addrFormat.composeAddress((int)newSegPos, segTargetId, length);
if(segTarget.getAppendPosition() + byteCnt >= sizeLimit) {
succ = false;
break;
}
// Transfer bytes from source to target
segSource.transferTo(oldSegPos, byteCnt, segTarget);
bytesTransferred += byteCnt;
sibTarget.add(index, (int)newSegPos);
_updateManager.addUpdate(index, byteCnt, newAddress, oldAddress, segTarget);
}
}
// Push whatever left into update queue
_updateManager.endUpdate(segTarget);
_log.info("bytes fastscanned from " + segSource.getSegmentId() + ": " + bytesTransferred + " time: " + c.tick() + " ms");
return succ;
} finally {
if(segSource.getClass() == BufferedSegment.class) {
segSource.close(false);
segSource = null;
}
}
} | [
"private",
"boolean",
"compact",
"(",
"Segment",
"segment",
",",
"SegmentIndexBuffer",
"sibSource",
",",
"Segment",
"segTarget",
")",
"throws",
"IOException",
"{",
"Segment",
"segSource",
"=",
"segment",
";",
"int",
"segSourceId",
"=",
"segSource",
".",
"getSegmen... | Compacts data from the specified source Segment into the specified target Segment.
@param segment - the source Segment, from which data is read.
@param sibSource - the source Segment Index Buffer, from which address indexes are read.
@param segTarget - the target Segment, to which data is written.
@return <code>true</code> if the source Segment is compacted successfully.
Otherwise, <code>false</code>.
@throws IOException if this operation can not be finished properly. | [
"Compacts",
"data",
"from",
"the",
"specified",
"source",
"Segment",
"into",
"the",
"specified",
"target",
"Segment",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArrayCompactor.java#L462-L527 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArrayCompactor.java | SimpleDataArrayCompactor.run | @Override
public void run() {
while(_enabled) {
if(_newCycle.compareAndSet(true, false)) {
// One and only one compactor is at work.
_lock.lock();
try {
reset();
_state = State.INIT;
_log.info("cycle init");
// Flush segment index buffers
flushSegmentIndexBuffers();
// Free compacted segments
freeCompactedSegments();
// Inspect the array
if(!inspect()) continue;
// Compact the array
if(!compact()) continue;
} catch(Exception e) {
_log.error("compaction failure", e);
} finally {
reset();
_state = State.DONE;
_log.info("cycle done");
_lock.unlock();
}
} else {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
_log.warn(e.getMessage());
}
}
}
} | java | @Override
public void run() {
while(_enabled) {
if(_newCycle.compareAndSet(true, false)) {
// One and only one compactor is at work.
_lock.lock();
try {
reset();
_state = State.INIT;
_log.info("cycle init");
// Flush segment index buffers
flushSegmentIndexBuffers();
// Free compacted segments
freeCompactedSegments();
// Inspect the array
if(!inspect()) continue;
// Compact the array
if(!compact()) continue;
} catch(Exception e) {
_log.error("compaction failure", e);
} finally {
reset();
_state = State.DONE;
_log.info("cycle done");
_lock.unlock();
}
} else {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
_log.warn(e.getMessage());
}
}
}
} | [
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"while",
"(",
"_enabled",
")",
"{",
"if",
"(",
"_newCycle",
".",
"compareAndSet",
"(",
"true",
",",
"false",
")",
")",
"{",
"// One and only one compactor is at work.",
"_lock",
".",
"lock",
"(",
")"... | Compacting Segments. | [
"Compacting",
"Segments",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArrayCompactor.java#L532-L571 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/SimpleDataArrayCompactor.java | SimpleDataArrayCompactor.getByteBuffer | protected ByteBuffer getByteBuffer(int bufferLength) {
if(_buffer == null) {
_buffer = ByteBuffer.wrap(new byte[bufferLength]);
_log.info("ByteBuffer allocated for buffering");
}
return _buffer;
} | java | protected ByteBuffer getByteBuffer(int bufferLength) {
if(_buffer == null) {
_buffer = ByteBuffer.wrap(new byte[bufferLength]);
_log.info("ByteBuffer allocated for buffering");
}
return _buffer;
} | [
"protected",
"ByteBuffer",
"getByteBuffer",
"(",
"int",
"bufferLength",
")",
"{",
"if",
"(",
"_buffer",
"==",
"null",
")",
"{",
"_buffer",
"=",
"ByteBuffer",
".",
"wrap",
"(",
"new",
"byte",
"[",
"bufferLength",
"]",
")",
";",
"_log",
".",
"info",
"(",
... | Gets the buffer for speeding up compaction.
@param bufferLength - the length of buffer. | [
"Gets",
"the",
"buffer",
"for",
"speeding",
"up",
"compaction",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/SimpleDataArrayCompactor.java#L685-L692 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cobol/model/CobolDataItem.java | CobolDataItem.toStringRenames | private void toStringRenames(final StringBuilder sb) {
if (getRenamesSubject() != null) {
sb.append(',');
sb.append("renamesSubject:" + getRenamesSubject());
}
if (getRenamesSubjectRange() != null) {
sb.append(',');
sb.append("renamesSubjectRange:" + getRenamesSubjectRange());
}
} | java | private void toStringRenames(final StringBuilder sb) {
if (getRenamesSubject() != null) {
sb.append(',');
sb.append("renamesSubject:" + getRenamesSubject());
}
if (getRenamesSubjectRange() != null) {
sb.append(',');
sb.append("renamesSubjectRange:" + getRenamesSubjectRange());
}
} | [
"private",
"void",
"toStringRenames",
"(",
"final",
"StringBuilder",
"sb",
")",
"{",
"if",
"(",
"getRenamesSubject",
"(",
")",
"!=",
"null",
")",
"{",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"sb",
".",
"append",
"(",
"\"renamesSubject:\"",
"+",
"... | Pretty printing for a renames entry.
@param sb the string builder | [
"Pretty",
"printing",
"for",
"a",
"renames",
"entry",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cobol/model/CobolDataItem.java#L831-L841 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cobol/model/CobolDataItem.java | CobolDataItem.toStringCondition | private void toStringCondition(final StringBuilder sb) {
if (getConditionLiterals().size() > 0) {
toStringList(sb, getConditionLiterals(), "conditionLiterals");
}
if (getConditionRanges().size() > 0) {
toStringList(sb, getConditionRanges(), "conditionRanges");
}
} | java | private void toStringCondition(final StringBuilder sb) {
if (getConditionLiterals().size() > 0) {
toStringList(sb, getConditionLiterals(), "conditionLiterals");
}
if (getConditionRanges().size() > 0) {
toStringList(sb, getConditionRanges(), "conditionRanges");
}
} | [
"private",
"void",
"toStringCondition",
"(",
"final",
"StringBuilder",
"sb",
")",
"{",
"if",
"(",
"getConditionLiterals",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"toStringList",
"(",
"sb",
",",
"getConditionLiterals",
"(",
")",
",",
"\"conditi... | Pretty printing for a condition entry.
@param sb the string builder | [
"Pretty",
"printing",
"for",
"a",
"condition",
"entry",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cobol/model/CobolDataItem.java#L848-L856 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cobol/model/CobolDataItem.java | CobolDataItem.toStringList | private void toStringList(final StringBuilder sb, final List < ? > list,
final String title) {
sb.append(',');
sb.append(title + ":[");
boolean first = true;
for (Object child : list) {
if (!first) {
sb.append(",");
} else {
first = false;
}
sb.append(child.toString());
}
sb.append("]");
} | java | private void toStringList(final StringBuilder sb, final List < ? > list,
final String title) {
sb.append(',');
sb.append(title + ":[");
boolean first = true;
for (Object child : list) {
if (!first) {
sb.append(",");
} else {
first = false;
}
sb.append(child.toString());
}
sb.append("]");
} | [
"private",
"void",
"toStringList",
"(",
"final",
"StringBuilder",
"sb",
",",
"final",
"List",
"<",
"?",
">",
"list",
",",
"final",
"String",
"title",
")",
"{",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"sb",
".",
"append",
"(",
"title",
"+",
"\... | Adds list elements to a string builder.
@param sb the string builder
@param list list of elements
@param title name of elements list | [
"Adds",
"list",
"elements",
"to",
"a",
"string",
"builder",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cobol/model/CobolDataItem.java#L865-L879 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/entry/EntryValueIntFactory.java | EntryValueIntFactory.reinitValue | @Override
public void reinitValue(DataReader in, EntryValueInt value) throws IOException {
value.reinit(in.readInt(), /* array position */
in.readInt(), /* data value */
in.readLong() /* SCN value */);
} | java | @Override
public void reinitValue(DataReader in, EntryValueInt value) throws IOException {
value.reinit(in.readInt(), /* array position */
in.readInt(), /* data value */
in.readLong() /* SCN value */);
} | [
"@",
"Override",
"public",
"void",
"reinitValue",
"(",
"DataReader",
"in",
",",
"EntryValueInt",
"value",
")",
"throws",
"IOException",
"{",
"value",
".",
"reinit",
"(",
"in",
".",
"readInt",
"(",
")",
",",
"/* array position */",
"in",
".",
"readInt",
"(",
... | Read data from stream to populate an EntryValueInt.
@param in
data reader for EntryValueInt.
@param value
an EntryValueInt to populate.
@throws IOException | [
"Read",
"data",
"from",
"stream",
"to",
"populate",
"an",
"EntryValueInt",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/entry/EntryValueIntFactory.java#L68-L73 | train |
oehf/ipf-oht-atna | context/src/main/java/org/openhealthtools/ihe/atna/context/SecurityContextInitializer.java | SecurityContextInitializer.initializeDefaultModules | private static void initializeDefaultModules(SecurityContext context)
{
if (context.isInitialized()) {
return;
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("SecurityContext default module initializer starting");
}
String moduleName;
// Loop through the module names
for (int i=0; i<DEFAULT_MODULES.length; i++) {
moduleName = DEFAULT_MODULES[i];
try {
LOGGER.debug(moduleName + MODULE_INITIALIZER_CLASS);
// Get a class instance for the module initializer
Class<?> clazz = Class.forName(moduleName + MODULE_INITIALIZER_CLASS);
// Get the method instance for the module initializer's initialization method
Method method = clazz.getMethod(MODULE_INITIALIZER_METHOD, (Class[])null);
// Invoke the initialization method
Object invokeResult = method.invoke(clazz.newInstance(), (Object[])null);
// Validate that the result of the initialization is a valid module context
if (invokeResult instanceof AbstractModuleContext) {
// Register the module context
context.registerModuleContext(moduleName, (AbstractModuleContext)invokeResult);
} else {
throw new IllegalArgumentException("Initializer method did not return correct type");
}
if (LOGGER.isInfoEnabled()) {
LOGGER.info("SecurityContext module "+ moduleName + " initialized");
}
} catch (ClassNotFoundException cnfe) {
LOGGER.warn("SecurityContext module "+ moduleName + " not found, skipping.");
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Stack trace: ", cnfe);
}
} catch (NoSuchMethodException nsme) {
LOGGER.warn("SecurityContext module "+ moduleName + " does not support default initialization, skipping.", nsme);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Stack trace: ", nsme);
}
} catch (Throwable t) {
LOGGER.error("Error initializing SecurityContext module "+ moduleName, t);
} finally {
}
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("SecurityContext default module initializer ending");
}
} | java | private static void initializeDefaultModules(SecurityContext context)
{
if (context.isInitialized()) {
return;
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("SecurityContext default module initializer starting");
}
String moduleName;
// Loop through the module names
for (int i=0; i<DEFAULT_MODULES.length; i++) {
moduleName = DEFAULT_MODULES[i];
try {
LOGGER.debug(moduleName + MODULE_INITIALIZER_CLASS);
// Get a class instance for the module initializer
Class<?> clazz = Class.forName(moduleName + MODULE_INITIALIZER_CLASS);
// Get the method instance for the module initializer's initialization method
Method method = clazz.getMethod(MODULE_INITIALIZER_METHOD, (Class[])null);
// Invoke the initialization method
Object invokeResult = method.invoke(clazz.newInstance(), (Object[])null);
// Validate that the result of the initialization is a valid module context
if (invokeResult instanceof AbstractModuleContext) {
// Register the module context
context.registerModuleContext(moduleName, (AbstractModuleContext)invokeResult);
} else {
throw new IllegalArgumentException("Initializer method did not return correct type");
}
if (LOGGER.isInfoEnabled()) {
LOGGER.info("SecurityContext module "+ moduleName + " initialized");
}
} catch (ClassNotFoundException cnfe) {
LOGGER.warn("SecurityContext module "+ moduleName + " not found, skipping.");
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Stack trace: ", cnfe);
}
} catch (NoSuchMethodException nsme) {
LOGGER.warn("SecurityContext module "+ moduleName + " does not support default initialization, skipping.", nsme);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Stack trace: ", nsme);
}
} catch (Throwable t) {
LOGGER.error("Error initializing SecurityContext module "+ moduleName, t);
} finally {
}
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("SecurityContext default module initializer ending");
}
} | [
"private",
"static",
"void",
"initializeDefaultModules",
"(",
"SecurityContext",
"context",
")",
"{",
"if",
"(",
"context",
".",
"isInitialized",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGE... | Initialize and register the contexts for modules that, by default,
are initialized with the security context
@param context The Security Context to perform initialzation routines | [
"Initialize",
"and",
"register",
"the",
"contexts",
"for",
"modules",
"that",
"by",
"default",
"are",
"initialized",
"with",
"the",
"security",
"context"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/context/src/main/java/org/openhealthtools/ihe/atna/context/SecurityContextInitializer.java#L78-L136 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/GenericAuditEventMessageImpl.java | GenericAuditEventMessageImpl.setAuditSourceId | public void setAuditSourceId(String sourceId, String enterpriseSiteId)
{
setAuditSourceId(sourceId, enterpriseSiteId, (RFC3881AuditSourceTypes[])null);
} | java | public void setAuditSourceId(String sourceId, String enterpriseSiteId)
{
setAuditSourceId(sourceId, enterpriseSiteId, (RFC3881AuditSourceTypes[])null);
} | [
"public",
"void",
"setAuditSourceId",
"(",
"String",
"sourceId",
",",
"String",
"enterpriseSiteId",
")",
"{",
"setAuditSourceId",
"(",
"sourceId",
",",
"enterpriseSiteId",
",",
"(",
"RFC3881AuditSourceTypes",
"[",
"]",
")",
"null",
")",
";",
"}"
] | Sets a Audit Source Identification block for a given Audit Source ID
and Audit Source Enterprise Site ID
@param sourceId The Audit Source ID to use
@param enterpriseSiteId The Audit Enterprise Site ID to use | [
"Sets",
"a",
"Audit",
"Source",
"Identification",
"block",
"for",
"a",
"given",
"Audit",
"Source",
"ID",
"and",
"Audit",
"Source",
"Enterprise",
"Site",
"ID"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/GenericAuditEventMessageImpl.java#L77-L80 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/GenericAuditEventMessageImpl.java | GenericAuditEventMessageImpl.setAuditSourceId | public void setAuditSourceId(String sourceId, String enterpriseSiteId, RFC3881AuditSourceTypes[] typeCodes)
{
addAuditSourceIdentification(sourceId, enterpriseSiteId, typeCodes);
} | java | public void setAuditSourceId(String sourceId, String enterpriseSiteId, RFC3881AuditSourceTypes[] typeCodes)
{
addAuditSourceIdentification(sourceId, enterpriseSiteId, typeCodes);
} | [
"public",
"void",
"setAuditSourceId",
"(",
"String",
"sourceId",
",",
"String",
"enterpriseSiteId",
",",
"RFC3881AuditSourceTypes",
"[",
"]",
"typeCodes",
")",
"{",
"addAuditSourceIdentification",
"(",
"sourceId",
",",
"enterpriseSiteId",
",",
"typeCodes",
")",
";",
... | Sets a Audit Source Identification block for a given Audit Source ID,
Audit Source Enterprise Site ID, and a list of audit source type codes
@param sourceId The Audit Source ID to use
@param enterpriseSiteId The Audit Enterprise Site ID to use
@param typeCodes The RFC 3881 Audit Source Type codes to use | [
"Sets",
"a",
"Audit",
"Source",
"Identification",
"block",
"for",
"a",
"given",
"Audit",
"Source",
"ID",
"Audit",
"Source",
"Enterprise",
"Site",
"ID",
"and",
"a",
"list",
"of",
"audit",
"source",
"type",
"codes"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/GenericAuditEventMessageImpl.java#L103-L106 | train |
jingwei/krati | krati-main/src/retention/java/krati/retention/policy/RetentionPolicyOnTime.java | RetentionPolicyOnTime.setRetention | public void setRetention(long duration, TimeUnit timeUnit) {
this._duration = Math.max(1, duration);
this._timeUnit = timeUnit;
long millis = TimeUnit.MILLISECONDS == timeUnit ?
_duration : TimeUnit.MILLISECONDS.convert(_duration, timeUnit);
_timeMillis = Math.max(millis, MIN_DURATION_MILLIS);
} | java | public void setRetention(long duration, TimeUnit timeUnit) {
this._duration = Math.max(1, duration);
this._timeUnit = timeUnit;
long millis = TimeUnit.MILLISECONDS == timeUnit ?
_duration : TimeUnit.MILLISECONDS.convert(_duration, timeUnit);
_timeMillis = Math.max(millis, MIN_DURATION_MILLIS);
} | [
"public",
"void",
"setRetention",
"(",
"long",
"duration",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"this",
".",
"_duration",
"=",
"Math",
".",
"max",
"(",
"1",
",",
"duration",
")",
";",
"this",
".",
"_timeUnit",
"=",
"timeUnit",
";",
"long",
"millis",
... | Sets the retention duration period of this policy.
@param duration - the retention duration
@param timeUnit - the time unit as defined by {@link TimeUnit} | [
"Sets",
"the",
"retention",
"duration",
"period",
"of",
"this",
"policy",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/retention/java/krati/retention/policy/RetentionPolicyOnTime.java#L97-L104 | train |
apptik/jus | jus-java/src/main/java/io/apptik/comm/jus/toolbox/PoolingByteArrayOutputStream.java | PoolingByteArrayOutputStream.expand | private void expand(int i) {
/* Can the buffer handle @i more bytes, if not expand it */
if (count + i <= buf.length) {
return;
}
byte[] newbuf = mPool.getBuf((count + i) * 2);
System.arraycopy(buf, 0, newbuf, 0, count);
mPool.returnBuf(buf);
buf = newbuf;
} | java | private void expand(int i) {
/* Can the buffer handle @i more bytes, if not expand it */
if (count + i <= buf.length) {
return;
}
byte[] newbuf = mPool.getBuf((count + i) * 2);
System.arraycopy(buf, 0, newbuf, 0, count);
mPool.returnBuf(buf);
buf = newbuf;
} | [
"private",
"void",
"expand",
"(",
"int",
"i",
")",
"{",
"/* Can the buffer handle @i more bytes, if not expand it */",
"if",
"(",
"count",
"+",
"i",
"<=",
"buf",
".",
"length",
")",
"{",
"return",
";",
"}",
"byte",
"[",
"]",
"newbuf",
"=",
"mPool",
".",
"g... | Ensures there is enough space in the buffer for the given number of additional bytes. | [
"Ensures",
"there",
"is",
"enough",
"space",
"in",
"the",
"buffer",
"for",
"the",
"given",
"number",
"of",
"additional",
"bytes",
"."
] | 8a37a21b41f897d68eaeaab07368ec22a1e5a60e | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/jus-java/src/main/java/io/apptik/comm/jus/toolbox/PoolingByteArrayOutputStream.java#L72-L81 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2XsdIO.java | Cob2XsdIO.checkCobolSourceFile | protected void checkCobolSourceFile(final File cobolSourceFile)
throws IOException {
if (cobolSourceFile == null) {
throw new IOException("You must provide a COBOL source file");
}
if (!cobolSourceFile.exists()) {
throw new IOException("COBOL source file " + cobolSourceFile
+ " not found");
}
} | java | protected void checkCobolSourceFile(final File cobolSourceFile)
throws IOException {
if (cobolSourceFile == null) {
throw new IOException("You must provide a COBOL source file");
}
if (!cobolSourceFile.exists()) {
throw new IOException("COBOL source file " + cobolSourceFile
+ " not found");
}
} | [
"protected",
"void",
"checkCobolSourceFile",
"(",
"final",
"File",
"cobolSourceFile",
")",
"throws",
"IOException",
"{",
"if",
"(",
"cobolSourceFile",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"You must provide a COBOL source file\"",
")",
";",
"... | make sure the COBOL file is valid.
@param cobolSourceFile the COBOL source file
@throws IOException if file cannot be located | [
"make",
"sure",
"the",
"COBOL",
"file",
"is",
"valid",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2XsdIO.java#L92-L101 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2XsdIO.java | Cob2XsdIO.checkTarget | protected void checkTarget(final File target) throws IOException {
if (target == null) {
throw new IOException("You must provide a target directory or file");
}
if (!target.exists()) {
String extension = FilenameUtils.getExtension(target.getName());
if (extension.length() == 0) {
throw new IOException("Target folder " + target + " not found");
}
}
} | java | protected void checkTarget(final File target) throws IOException {
if (target == null) {
throw new IOException("You must provide a target directory or file");
}
if (!target.exists()) {
String extension = FilenameUtils.getExtension(target.getName());
if (extension.length() == 0) {
throw new IOException("Target folder " + target + " not found");
}
}
} | [
"protected",
"void",
"checkTarget",
"(",
"final",
"File",
"target",
")",
"throws",
"IOException",
"{",
"if",
"(",
"target",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"You must provide a target directory or file\"",
")",
";",
"}",
"if",
"(",
... | make sure the target, folder or file, is valid. We consider that target
files will have extensions. Its ok for a target file not to exist but
target folders must exist.
@param target the target folder or file
@throws IOException if file cannot be located | [
"make",
"sure",
"the",
"target",
"folder",
"or",
"file",
"is",
"valid",
".",
"We",
"consider",
"that",
"target",
"files",
"will",
"have",
"extensions",
".",
"Its",
"ok",
"for",
"a",
"target",
"file",
"not",
"to",
"exist",
"but",
"target",
"folders",
"mus... | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2XsdIO.java#L111-L121 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2XsdIO.java | Cob2XsdIO.getUniqueTargetNamespace | protected String getUniqueTargetNamespace(String targetNamespacePrefix,
final String baseName) throws IOException {
if (targetNamespacePrefix == null
|| targetNamespacePrefix.length() == 0) {
return null;
}
if (baseName == null || baseName.length() == 0) {
throw new IOException("No target basename was provided");
}
if (targetNamespacePrefix.charAt(targetNamespacePrefix.length() - 1) == '/') {
return targetNamespacePrefix + baseName;
} else {
return targetNamespacePrefix + '/' + baseName;
}
} | java | protected String getUniqueTargetNamespace(String targetNamespacePrefix,
final String baseName) throws IOException {
if (targetNamespacePrefix == null
|| targetNamespacePrefix.length() == 0) {
return null;
}
if (baseName == null || baseName.length() == 0) {
throw new IOException("No target basename was provided");
}
if (targetNamespacePrefix.charAt(targetNamespacePrefix.length() - 1) == '/') {
return targetNamespacePrefix + baseName;
} else {
return targetNamespacePrefix + '/' + baseName;
}
} | [
"protected",
"String",
"getUniqueTargetNamespace",
"(",
"String",
"targetNamespacePrefix",
",",
"final",
"String",
"baseName",
")",
"throws",
"IOException",
"{",
"if",
"(",
"targetNamespacePrefix",
"==",
"null",
"||",
"targetNamespacePrefix",
".",
"length",
"(",
")",
... | TargetNamespace, if it is not null, is completed with the baseName.
@param targetNamespacePrefix the target namespace prefix
@param baseName A name, derived from the COBOL file name, that can be
used to identify generated artifacts
@return the targetNamespace for the xml schema
@throws IOException if unable to create a namespace | [
"TargetNamespace",
"if",
"it",
"is",
"not",
"null",
"is",
"completed",
"with",
"the",
"baseName",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/Cob2XsdIO.java#L132-L149 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXAuditor.java | PIXAuditor.auditQueryEvent | protected void auditQueryEvent(boolean systemIsSource,
IHETransactionEventTypeCodes transaction, RFC3881EventOutcomeCodes eventOutcome,
String sourceFacility, String sourceApp, String sourceAltUserId, String sourceNetworkId,
String destinationFacility, String destinationApp, String destinationAltUserId, String destinationNetworkId,
String humanRequestor,
String hl7MessageId, String hl7QueryParameters,
String[] patientIds,
List<CodedValueType> purposesOfUse,
List<CodedValueType> userRoles)
{
// Create query event
QueryEvent queryEvent = new QueryEvent(systemIsSource, eventOutcome, transaction, purposesOfUse);
queryEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
// Set the source active participant
queryEvent.addSourceActiveParticipant(EventUtils.concatHL7FacilityApplication(sourceFacility,sourceApp), sourceAltUserId, null, sourceNetworkId, true);
// Set the human requestor active participant
if (!EventUtils.isEmptyOrNull(humanRequestor)) {
queryEvent.addHumanRequestorActiveParticipant(humanRequestor, null, null, userRoles);
}
// Set the destination active participant
queryEvent.addDestinationActiveParticipant(EventUtils.concatHL7FacilityApplication(destinationFacility,destinationApp), destinationAltUserId, null, destinationNetworkId, false);
// Add a patient participant object for each patient id
if (!EventUtils.isEmptyOrNull(patientIds)) {
for (int i=0; i<patientIds.length; i++) {
queryEvent.addPatientParticipantObject(patientIds[i]);
}
}
byte[] queryParamsBytes = null, msgControlBytes = null;
if (hl7QueryParameters != null) {
queryParamsBytes = hl7QueryParameters.getBytes();
}
if (hl7MessageId != null) {
msgControlBytes = hl7MessageId.getBytes();
}
// Add the Query participant object
queryEvent.addQueryParticipantObject(null, null, queryParamsBytes, msgControlBytes, transaction);
audit(queryEvent);
} | java | protected void auditQueryEvent(boolean systemIsSource,
IHETransactionEventTypeCodes transaction, RFC3881EventOutcomeCodes eventOutcome,
String sourceFacility, String sourceApp, String sourceAltUserId, String sourceNetworkId,
String destinationFacility, String destinationApp, String destinationAltUserId, String destinationNetworkId,
String humanRequestor,
String hl7MessageId, String hl7QueryParameters,
String[] patientIds,
List<CodedValueType> purposesOfUse,
List<CodedValueType> userRoles)
{
// Create query event
QueryEvent queryEvent = new QueryEvent(systemIsSource, eventOutcome, transaction, purposesOfUse);
queryEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
// Set the source active participant
queryEvent.addSourceActiveParticipant(EventUtils.concatHL7FacilityApplication(sourceFacility,sourceApp), sourceAltUserId, null, sourceNetworkId, true);
// Set the human requestor active participant
if (!EventUtils.isEmptyOrNull(humanRequestor)) {
queryEvent.addHumanRequestorActiveParticipant(humanRequestor, null, null, userRoles);
}
// Set the destination active participant
queryEvent.addDestinationActiveParticipant(EventUtils.concatHL7FacilityApplication(destinationFacility,destinationApp), destinationAltUserId, null, destinationNetworkId, false);
// Add a patient participant object for each patient id
if (!EventUtils.isEmptyOrNull(patientIds)) {
for (int i=0; i<patientIds.length; i++) {
queryEvent.addPatientParticipantObject(patientIds[i]);
}
}
byte[] queryParamsBytes = null, msgControlBytes = null;
if (hl7QueryParameters != null) {
queryParamsBytes = hl7QueryParameters.getBytes();
}
if (hl7MessageId != null) {
msgControlBytes = hl7MessageId.getBytes();
}
// Add the Query participant object
queryEvent.addQueryParticipantObject(null, null, queryParamsBytes, msgControlBytes, transaction);
audit(queryEvent);
} | [
"protected",
"void",
"auditQueryEvent",
"(",
"boolean",
"systemIsSource",
",",
"IHETransactionEventTypeCodes",
"transaction",
",",
"RFC3881EventOutcomeCodes",
"eventOutcome",
",",
"String",
"sourceFacility",
",",
"String",
"sourceApp",
",",
"String",
"sourceAltUserId",
",",... | Audit a QUERY event for PIX and PDQ transactions. Useful for PIX Query, PDQ Query,
and PDVQ Query in the PIX Manager as well as the PIX and PDQ Consumer
@param systemIsSource Whether the system sending the message is the source active participant
@param transaction IHE Transaction sending the message
@param eventOutcome The event outcome indicator
@param sourceFacility Source (sending/receiving) facility, from the MSH segment
@param sourceApp Source (sending/receiving) application, from the MSH segment
@param sourceAltUserId Source Active Participant Alternate User ID
@param sourceNetworkId Source Active Participant Network ID
@param destinationFacility Destination (sending/receiving) facility, from the MSH segment
@param destinationApp Destination (sending/receiving) application, from the MSH segment
@param destinationAltUserId Destination Active Participant Alternate User ID
@param destinationNetworkId Destination Active Participant Network ID
@param humanRequestor Identity of the human that initiated the transaction (if known)
@param hl7MessageId The HL7 Message ID (v2 from the MSH segment field 10, v3 from message.Id)
@param hl7QueryParameters The HL7 Query Parameters from the QPD segment
@param patientIds List of patient IDs that were seen in this transaction
@param purposesOfUse purpose of use codes (may be taken from XUA token)
@param userRoles roles of the human user (may be taken from XUA token) | [
"Audit",
"a",
"QUERY",
"event",
"for",
"PIX",
"and",
"PDQ",
"transactions",
".",
"Useful",
"for",
"PIX",
"Query",
"PDQ",
"Query",
"and",
"PDVQ",
"Query",
"in",
"the",
"PIX",
"Manager",
"as",
"well",
"as",
"the",
"PIX",
"and",
"PDQ",
"Consumer"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXAuditor.java#L55-L95 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/context/AuditorModuleContext.java | AuditorModuleContext.getContext | public static AuditorModuleContext getContext()
{
SecurityContext securityContext = SecurityContextFactory.getSecurityContext();
if (!securityContext.isInitialized()) {
securityContext.initialize();
}
AbstractModuleContext moduleContext = securityContext.getModuleContext(CONTEXT_ID);
if (null == moduleContext || !(moduleContext instanceof AuditorModuleContext)) {
moduleContext = ContextInitializer.defaultInitialize();
securityContext.registerModuleContext(CONTEXT_ID, moduleContext);
}
return (AuditorModuleContext)moduleContext;
} | java | public static AuditorModuleContext getContext()
{
SecurityContext securityContext = SecurityContextFactory.getSecurityContext();
if (!securityContext.isInitialized()) {
securityContext.initialize();
}
AbstractModuleContext moduleContext = securityContext.getModuleContext(CONTEXT_ID);
if (null == moduleContext || !(moduleContext instanceof AuditorModuleContext)) {
moduleContext = ContextInitializer.defaultInitialize();
securityContext.registerModuleContext(CONTEXT_ID, moduleContext);
}
return (AuditorModuleContext)moduleContext;
} | [
"public",
"static",
"AuditorModuleContext",
"getContext",
"(",
")",
"{",
"SecurityContext",
"securityContext",
"=",
"SecurityContextFactory",
".",
"getSecurityContext",
"(",
")",
";",
"if",
"(",
"!",
"securityContext",
".",
"isInitialized",
"(",
")",
")",
"{",
"se... | Returns the current singleton instance of the Auditor Module Context from the
ThreadLocal cache. If the ThreadLocal cache has not been initialized or does not contain
this context, then create and initialize module context, register in the ThreadLocal
and return the new instance.
@return Context singleton | [
"Returns",
"the",
"current",
"singleton",
"instance",
"of",
"the",
"Auditor",
"Module",
"Context",
"from",
"the",
"ThreadLocal",
"cache",
".",
"If",
"the",
"ThreadLocal",
"cache",
"has",
"not",
"been",
"initialized",
"or",
"does",
"not",
"contain",
"this",
"co... | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/context/AuditorModuleContext.java#L79-L93 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/context/AuditorModuleContext.java | AuditorModuleContext.getSender | public AuditMessageSender getSender()
{
if (customSender == null){
String transport = AuditorModuleContext.getContext().getConfig().getAuditRepositoryTransport();
if (transport.equalsIgnoreCase("TLS") ) {
return new TLSSyslogSenderImpl();
} else if (transport.equalsIgnoreCase("UDP") ){
return new UDPSyslogSenderImpl();
} else {
return new BSDSyslogSenderImpl();
}
}else
return customSender;
} | java | public AuditMessageSender getSender()
{
if (customSender == null){
String transport = AuditorModuleContext.getContext().getConfig().getAuditRepositoryTransport();
if (transport.equalsIgnoreCase("TLS") ) {
return new TLSSyslogSenderImpl();
} else if (transport.equalsIgnoreCase("UDP") ){
return new UDPSyslogSenderImpl();
} else {
return new BSDSyslogSenderImpl();
}
}else
return customSender;
} | [
"public",
"AuditMessageSender",
"getSender",
"(",
")",
"{",
"if",
"(",
"customSender",
"==",
"null",
")",
"{",
"String",
"transport",
"=",
"AuditorModuleContext",
".",
"getContext",
"(",
")",
".",
"getConfig",
"(",
")",
".",
"getAuditRepositoryTransport",
"(",
... | Gets the transport-specific sending instance used to
deliver audit messages to their destination
@return Audit message sender | [
"Gets",
"the",
"transport",
"-",
"specific",
"sending",
"instance",
"used",
"to",
"deliver",
"audit",
"messages",
"to",
"their",
"destination"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/context/AuditorModuleContext.java#L137-L150 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/context/AuditorModuleContext.java | AuditorModuleContext.getAuditor | public IHEAuditor getAuditor(String className, boolean useContextAuditorRegistry)
{
return getAuditor(AuditorFactory.getAuditorClassForClassName(className),useContextAuditorRegistry);
} | java | public IHEAuditor getAuditor(String className, boolean useContextAuditorRegistry)
{
return getAuditor(AuditorFactory.getAuditorClassForClassName(className),useContextAuditorRegistry);
} | [
"public",
"IHEAuditor",
"getAuditor",
"(",
"String",
"className",
",",
"boolean",
"useContextAuditorRegistry",
")",
"{",
"return",
"getAuditor",
"(",
"AuditorFactory",
".",
"getAuditorClassForClassName",
"(",
"className",
")",
",",
"useContextAuditorRegistry",
")",
";",... | Get an IHE Auditor instance from a fully-qualified class name
@param className Auditor class to use
@param useContextAuditorRegistry Whether to reuse cached auditors from context
@return Auditor instance | [
"Get",
"an",
"IHE",
"Auditor",
"instance",
"from",
"a",
"fully",
"-",
"qualified",
"class",
"name"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/context/AuditorModuleContext.java#L287-L290 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRegistryAuditor.java | XDSRegistryAuditor.getAuditor | public static XDSRegistryAuditor getAuditor()
{
AuditorModuleContext ctx = AuditorModuleContext.getContext();
return (XDSRegistryAuditor)ctx.getAuditor(XDSRegistryAuditor.class);
} | java | public static XDSRegistryAuditor getAuditor()
{
AuditorModuleContext ctx = AuditorModuleContext.getContext();
return (XDSRegistryAuditor)ctx.getAuditor(XDSRegistryAuditor.class);
} | [
"public",
"static",
"XDSRegistryAuditor",
"getAuditor",
"(",
")",
"{",
"AuditorModuleContext",
"ctx",
"=",
"AuditorModuleContext",
".",
"getContext",
"(",
")",
";",
"return",
"(",
"XDSRegistryAuditor",
")",
"ctx",
".",
"getAuditor",
"(",
"XDSRegistryAuditor",
".",
... | Get an instance of the XDS Document Registry Auditor from the
global context
@return XDS Document Registry Auditor instance | [
"Get",
"an",
"instance",
"of",
"the",
"XDS",
"Document",
"Registry",
"Auditor",
"from",
"the",
"global",
"context"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRegistryAuditor.java#L45-L49 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRegistryAuditor.java | XDSRegistryAuditor.auditRegistryQueryEvent | public void auditRegistryQueryEvent(
RFC3881EventOutcomeCodes eventOutcome,
String consumerUserId, String consumerUserName, String consumerIpAddress,
String registryEndpointUri,
String adhocQueryRequestPayload,
String patientId)
{
if (!isAuditorEnabled()) {
return;
}
auditQueryEvent(false,
new IHETransactionEventTypeCodes.RegistrySQLQuery(), eventOutcome,
getAuditSourceId(), getAuditEnterpriseSiteId(),
consumerUserId, null, consumerUserName, consumerIpAddress,
consumerUserName, consumerUserName, true,
registryEndpointUri, getSystemAltUserId(),
"", adhocQueryRequestPayload, "",
patientId, null, null);
} | java | public void auditRegistryQueryEvent(
RFC3881EventOutcomeCodes eventOutcome,
String consumerUserId, String consumerUserName, String consumerIpAddress,
String registryEndpointUri,
String adhocQueryRequestPayload,
String patientId)
{
if (!isAuditorEnabled()) {
return;
}
auditQueryEvent(false,
new IHETransactionEventTypeCodes.RegistrySQLQuery(), eventOutcome,
getAuditSourceId(), getAuditEnterpriseSiteId(),
consumerUserId, null, consumerUserName, consumerIpAddress,
consumerUserName, consumerUserName, true,
registryEndpointUri, getSystemAltUserId(),
"", adhocQueryRequestPayload, "",
patientId, null, null);
} | [
"public",
"void",
"auditRegistryQueryEvent",
"(",
"RFC3881EventOutcomeCodes",
"eventOutcome",
",",
"String",
"consumerUserId",
",",
"String",
"consumerUserName",
",",
"String",
"consumerIpAddress",
",",
"String",
"registryEndpointUri",
",",
"String",
"adhocQueryRequestPayload... | Audits an ITI-16 Registry SQL Query event for XDS.a Document Registry actors.
@param eventOutcome The event outcome indicator
@param consumerUserId The Active Participant UserID for the consumer (if using WS-Addressing)
@param consumerUserName The Active Participant UserName for the consumer (if using WS-Security / XUA)
@param consumerIpAddress The IP Address of the consumer that initiated the transaction
@param registryEndpointUri The URI of this registry's endpoint that received the transaction
@param adhocQueryRequestPayload The payload of the adhoc query request element
@param patientId The patient ID queried (if query pertained to a patient id) | [
"Audits",
"an",
"ITI",
"-",
"16",
"Registry",
"SQL",
"Query",
"event",
"for",
"XDS",
".",
"a",
"Document",
"Registry",
"actors",
"."
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRegistryAuditor.java#L89-L107 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRegistryAuditor.java | XDSRegistryAuditor.auditRegistryStoredQueryEvent | public void auditRegistryStoredQueryEvent(
RFC3881EventOutcomeCodes eventOutcome,
String consumerUserId, String consumerUserName, String consumerIpAddress,
String registryEndpointUri,
String storedQueryUUID, String adhocQueryRequestPayload, String homeCommunityId,
String patientId, List<CodedValueType> purposesOfUse, List<CodedValueType> userRoles)
{
if (!isAuditorEnabled()) {
return;
}
auditQueryEvent(false,
new IHETransactionEventTypeCodes.RegistryStoredQuery(), eventOutcome,
getAuditSourceId(), getAuditEnterpriseSiteId(),
consumerUserId, null, consumerUserName, consumerIpAddress,
consumerUserName, consumerUserName, false,
registryEndpointUri, getSystemAltUserId(),
storedQueryUUID, adhocQueryRequestPayload, homeCommunityId,
patientId, purposesOfUse, userRoles);
} | java | public void auditRegistryStoredQueryEvent(
RFC3881EventOutcomeCodes eventOutcome,
String consumerUserId, String consumerUserName, String consumerIpAddress,
String registryEndpointUri,
String storedQueryUUID, String adhocQueryRequestPayload, String homeCommunityId,
String patientId, List<CodedValueType> purposesOfUse, List<CodedValueType> userRoles)
{
if (!isAuditorEnabled()) {
return;
}
auditQueryEvent(false,
new IHETransactionEventTypeCodes.RegistryStoredQuery(), eventOutcome,
getAuditSourceId(), getAuditEnterpriseSiteId(),
consumerUserId, null, consumerUserName, consumerIpAddress,
consumerUserName, consumerUserName, false,
registryEndpointUri, getSystemAltUserId(),
storedQueryUUID, adhocQueryRequestPayload, homeCommunityId,
patientId, purposesOfUse, userRoles);
} | [
"public",
"void",
"auditRegistryStoredQueryEvent",
"(",
"RFC3881EventOutcomeCodes",
"eventOutcome",
",",
"String",
"consumerUserId",
",",
"String",
"consumerUserName",
",",
"String",
"consumerIpAddress",
",",
"String",
"registryEndpointUri",
",",
"String",
"storedQueryUUID",
... | Audits an ITI-18 Registry Stored Query event for XDS.a and XDS.b Document Registry actors.
@param eventOutcome The event outcome indicator
@param consumerUserId The Active Participant UserID for the consumer (if using WS-Addressing)
@param consumerUserName The Active Participant UserName for the consumer (if using WS-Security / XUA)
@param consumerIpAddress The IP Address of the consumer that initiated the transaction
@param registryEndpointUri The URI of this registry's endpoint that received the transaction
@param storedQueryUUID The UUID of the stored query
@param adhocQueryRequestPayload The payload of the adhoc query request element
@param homeCommunityId The home community id of the transaction (if present)
@param patientId The patient ID queried (if query pertained to a patient id)
@param purposesOfUse purpose of use codes (may be taken from XUA token)
@param userRoles roles of the human user (may be taken from XUA token) | [
"Audits",
"an",
"ITI",
"-",
"18",
"Registry",
"Stored",
"Query",
"event",
"for",
"XDS",
".",
"a",
"and",
"XDS",
".",
"b",
"Document",
"Registry",
"actors",
"."
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRegistryAuditor.java#L124-L142 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRegistryAuditor.java | XDSRegistryAuditor.auditRegisterEvent | protected void auditRegisterEvent(
IHETransactionEventTypeCodes transaction, RFC3881EventOutcomeCodes eventOutcome,
String repositoryUserId, String repositoryIpAddress,
String userName,
String registryEndpointUri,
String submissionSetUniqueId,
String patientId,
List<CodedValueType> purposesOfUse,
List<CodedValueType> userRoles)
{
ImportEvent importEvent = new ImportEvent(false, eventOutcome, transaction, purposesOfUse);
importEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
importEvent.addSourceActiveParticipant(repositoryUserId, null, null, repositoryIpAddress, true);
if (! EventUtils.isEmptyOrNull(userName)) {
importEvent.addHumanRequestorActiveParticipant(userName, null, userName, userRoles);
}
importEvent.addDestinationActiveParticipant(registryEndpointUri, getSystemAltUserId(), null, EventUtils.getAddressForUrl(registryEndpointUri, false), false);
if (!EventUtils.isEmptyOrNull(patientId)) {
importEvent.addPatientParticipantObject(patientId);
}
importEvent.addSubmissionSetParticipantObject(submissionSetUniqueId);
audit(importEvent);
} | java | protected void auditRegisterEvent(
IHETransactionEventTypeCodes transaction, RFC3881EventOutcomeCodes eventOutcome,
String repositoryUserId, String repositoryIpAddress,
String userName,
String registryEndpointUri,
String submissionSetUniqueId,
String patientId,
List<CodedValueType> purposesOfUse,
List<CodedValueType> userRoles)
{
ImportEvent importEvent = new ImportEvent(false, eventOutcome, transaction, purposesOfUse);
importEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
importEvent.addSourceActiveParticipant(repositoryUserId, null, null, repositoryIpAddress, true);
if (! EventUtils.isEmptyOrNull(userName)) {
importEvent.addHumanRequestorActiveParticipant(userName, null, userName, userRoles);
}
importEvent.addDestinationActiveParticipant(registryEndpointUri, getSystemAltUserId(), null, EventUtils.getAddressForUrl(registryEndpointUri, false), false);
if (!EventUtils.isEmptyOrNull(patientId)) {
importEvent.addPatientParticipantObject(patientId);
}
importEvent.addSubmissionSetParticipantObject(submissionSetUniqueId);
audit(importEvent);
} | [
"protected",
"void",
"auditRegisterEvent",
"(",
"IHETransactionEventTypeCodes",
"transaction",
",",
"RFC3881EventOutcomeCodes",
"eventOutcome",
",",
"String",
"repositoryUserId",
",",
"String",
"repositoryIpAddress",
",",
"String",
"userName",
",",
"String",
"registryEndpoint... | Generically sends audit messages for XDS Document Registry Register Document Set events
@param transaction The specific IHE Transaction (ITI-15 or ITI-41)
@param eventOutcome The event outcome indicator
@param repositoryUserId The Active Participant UserID for the repository (if using WS-Addressing)
@param repositoryIpAddress The IP Address of the repository that initiated the transaction
@param userName user name from XUA
@param registryEndpointUri The URI of this registry's endpoint that received the transaction
@param submissionSetUniqueId The UniqueID of the Submission Set provided
@param patientId The Patient Id that this submission pertains to
@param purposesOfUse purpose of use codes (may be taken from XUA token)
@param userRoles roles of the human user (may be taken from XUA token) | [
"Generically",
"sends",
"audit",
"messages",
"for",
"XDS",
"Document",
"Registry",
"Register",
"Document",
"Set",
"events"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRegistryAuditor.java#L215-L238 | train |
oehf/ipf-oht-atna | nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomain.java | SecurityDomain.fixKeyManagers | private void fixKeyManagers() {
// If the key manager factory is null, do not continue
if (null == keyManagerFactory || null == keyManagerFactory.getKeyManagers()) {
return;
}
KeyManager[] defaultKeyManagers = keyManagerFactory.getKeyManagers();
KeyManager[] newKeyManagers = new KeyManager[defaultKeyManagers.length];
KeyManager mgr = null;
for (int i = 0; i < defaultKeyManagers.length; i++) {
mgr = defaultKeyManagers[i];
// If we're looking at an X509 Key manager, then wrap it in our
// alias-selective manager
if (mgr instanceof X509KeyManager) {
mgr = new AliasSensitiveX509KeyManager(this, (X509KeyManager) mgr);
}
newKeyManagers[i] = mgr;
}
keyManagers = newKeyManagers;
} | java | private void fixKeyManagers() {
// If the key manager factory is null, do not continue
if (null == keyManagerFactory || null == keyManagerFactory.getKeyManagers()) {
return;
}
KeyManager[] defaultKeyManagers = keyManagerFactory.getKeyManagers();
KeyManager[] newKeyManagers = new KeyManager[defaultKeyManagers.length];
KeyManager mgr = null;
for (int i = 0; i < defaultKeyManagers.length; i++) {
mgr = defaultKeyManagers[i];
// If we're looking at an X509 Key manager, then wrap it in our
// alias-selective manager
if (mgr instanceof X509KeyManager) {
mgr = new AliasSensitiveX509KeyManager(this, (X509KeyManager) mgr);
}
newKeyManagers[i] = mgr;
}
keyManagers = newKeyManagers;
} | [
"private",
"void",
"fixKeyManagers",
"(",
")",
"{",
"// If the key manager factory is null, do not continue",
"if",
"(",
"null",
"==",
"keyManagerFactory",
"||",
"null",
"==",
"keyManagerFactory",
".",
"getKeyManagers",
"(",
")",
")",
"{",
"return",
";",
"}",
"KeyMa... | If a keystore alias is defined, then override the key manager assigned
to with an alias-sensitive wrapper that selects the proper key from your
assigned key alias. | [
"If",
"a",
"keystore",
"alias",
"is",
"defined",
"then",
"override",
"the",
"key",
"manager",
"assigned",
"to",
"with",
"an",
"alias",
"-",
"sensitive",
"wrapper",
"that",
"selects",
"the",
"proper",
"key",
"from",
"your",
"assigned",
"key",
"alias",
"."
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomain.java#L438-L458 | train |
rpatil26/webutilities | src/main/java/com/googlecode/webutilities/filters/ResponseCacheFilter.java | ResponseCacheFilter.init | @Override
public void init(FilterConfig filterConfig) throws ServletException {
super.init(filterConfig);
int reloadTime = readInt(filterConfig.getInitParameter(INIT_PARAM_RELOAD_TIME), 0);
this.resetTime = readInt(filterConfig.getInitParameter(INIT_PARAM_RESET_TIME), resetTime);
this.cacheKeyFormat = readString(filterConfig.getInitParameter(INIT_PARAM_CAHE_KEY_FORMAT), DEFAULT_CACHE_KEY_FORMAT);
lastResetTime = new Date().getTime();
CacheConfig<String, CachedResponse> cacheConfig = new CacheConfig<>();
String providerValue = readString(filterConfig.getInitParameter(INIT_PARAM_CACHE_PROVIDER), null);
if (providerValue != null)
cacheConfig.setProvider(CacheConfig.CacheProvider.valueOf(providerValue.toUpperCase()));
String cacheHost = filterConfig.getInitParameter(INIT_PARAM_CACHE_HOST);
cacheConfig.setHostname(cacheHost);
int cachePort = readInt(filterConfig.getInitParameter(INIT_PARAM_CACHE_PORT), 0);
cacheConfig.setPortNumber(cachePort);
if (!CacheFactory.isCacheProvider(cache, cacheConfig.getProvider())) {
try {
cache = CacheFactory.getCache(cacheConfig);
} catch (Exception ex) {
LOGGER.debug("Failed to initialize Cache Config: {}. Falling back to default Cache Service.", cacheConfig);
cache = CacheFactory.<String, CachedResponse>getDefaultCache();
}
}
LOGGER.debug("Cache Filter initialized with: " +
"{}:{},\n" +
"{}:{},\n" +
"{}:{},\n" +
"{}:{},\n" +
"{}:{}",
INIT_PARAM_CACHE_PROVIDER, providerValue,
INIT_PARAM_CACHE_HOST, cacheHost,
INIT_PARAM_CACHE_PORT, String.valueOf(cachePort),
INIT_PARAM_RELOAD_TIME, String.valueOf(reloadTime),
INIT_PARAM_RESET_TIME, String.valueOf(resetTime));
} | java | @Override
public void init(FilterConfig filterConfig) throws ServletException {
super.init(filterConfig);
int reloadTime = readInt(filterConfig.getInitParameter(INIT_PARAM_RELOAD_TIME), 0);
this.resetTime = readInt(filterConfig.getInitParameter(INIT_PARAM_RESET_TIME), resetTime);
this.cacheKeyFormat = readString(filterConfig.getInitParameter(INIT_PARAM_CAHE_KEY_FORMAT), DEFAULT_CACHE_KEY_FORMAT);
lastResetTime = new Date().getTime();
CacheConfig<String, CachedResponse> cacheConfig = new CacheConfig<>();
String providerValue = readString(filterConfig.getInitParameter(INIT_PARAM_CACHE_PROVIDER), null);
if (providerValue != null)
cacheConfig.setProvider(CacheConfig.CacheProvider.valueOf(providerValue.toUpperCase()));
String cacheHost = filterConfig.getInitParameter(INIT_PARAM_CACHE_HOST);
cacheConfig.setHostname(cacheHost);
int cachePort = readInt(filterConfig.getInitParameter(INIT_PARAM_CACHE_PORT), 0);
cacheConfig.setPortNumber(cachePort);
if (!CacheFactory.isCacheProvider(cache, cacheConfig.getProvider())) {
try {
cache = CacheFactory.getCache(cacheConfig);
} catch (Exception ex) {
LOGGER.debug("Failed to initialize Cache Config: {}. Falling back to default Cache Service.", cacheConfig);
cache = CacheFactory.<String, CachedResponse>getDefaultCache();
}
}
LOGGER.debug("Cache Filter initialized with: " +
"{}:{},\n" +
"{}:{},\n" +
"{}:{},\n" +
"{}:{},\n" +
"{}:{}",
INIT_PARAM_CACHE_PROVIDER, providerValue,
INIT_PARAM_CACHE_HOST, cacheHost,
INIT_PARAM_CACHE_PORT, String.valueOf(cachePort),
INIT_PARAM_RELOAD_TIME, String.valueOf(reloadTime),
INIT_PARAM_RESET_TIME, String.valueOf(resetTime));
} | [
"@",
"Override",
"public",
"void",
"init",
"(",
"FilterConfig",
"filterConfig",
")",
"throws",
"ServletException",
"{",
"super",
".",
"init",
"(",
"filterConfig",
")",
";",
"int",
"reloadTime",
"=",
"readInt",
"(",
"filterConfig",
".",
"getInitParameter",
"(",
... | eg. "queryString, header=X-Requested-By, parameter=username". URI is always part of key | [
"eg",
".",
"queryString",
"header",
"=",
"X",
"-",
"Requested",
"-",
"By",
"parameter",
"=",
"username",
".",
"URI",
"is",
"always",
"part",
"of",
"key"
] | fdd04f59923cd0f2d80540b861aa0268da99f5c7 | https://github.com/rpatil26/webutilities/blob/fdd04f59923cd0f2d80540b861aa0268da99f5c7/src/main/java/com/googlecode/webutilities/filters/ResponseCacheFilter.java#L114-L157 | train |
rpatil26/webutilities | src/main/java/com/googlecode/webutilities/filters/ResponseCacheFilter.java | ResponseCacheFilter.generateCacheKeyForTheRequest | protected String generateCacheKeyForTheRequest(HttpServletRequest request) {
StringBuilder cacheKey = new StringBuilder();
cacheKey.append(request.getRequestURI());
String[] keyAttributes = this.cacheKeyFormat.split(",");
for (String attr : keyAttributes) {
String keyAttr = attr.trim().toLowerCase();
if (keyAttr.equalsIgnoreCase("queryString") && request.getQueryString() != null) {
cacheKey.append("+").append(request.getQueryString());
} else if (keyAttr.startsWith("header=")) {
cacheKey.append("+").append(request.getHeader(keyAttr.substring(7).trim()));
} else if (keyAttr.startsWith("parameter=")) {
cacheKey.append("+").append(request.getHeader(keyAttr.substring(9).trim()));
}
}
return cacheKey.toString();
} | java | protected String generateCacheKeyForTheRequest(HttpServletRequest request) {
StringBuilder cacheKey = new StringBuilder();
cacheKey.append(request.getRequestURI());
String[] keyAttributes = this.cacheKeyFormat.split(",");
for (String attr : keyAttributes) {
String keyAttr = attr.trim().toLowerCase();
if (keyAttr.equalsIgnoreCase("queryString") && request.getQueryString() != null) {
cacheKey.append("+").append(request.getQueryString());
} else if (keyAttr.startsWith("header=")) {
cacheKey.append("+").append(request.getHeader(keyAttr.substring(7).trim()));
} else if (keyAttr.startsWith("parameter=")) {
cacheKey.append("+").append(request.getHeader(keyAttr.substring(9).trim()));
}
}
return cacheKey.toString();
} | [
"protected",
"String",
"generateCacheKeyForTheRequest",
"(",
"HttpServletRequest",
"request",
")",
"{",
"StringBuilder",
"cacheKey",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"cacheKey",
".",
"append",
"(",
"request",
".",
"getRequestURI",
"(",
")",
")",
";",
... | Generate the cache key for the specific request by using the cacheKeyFormat init param
You can specify comma separated list of attributes that you want to use to build the cache key.
URI is by default part of the cache key. Using cacheKeyFormat params you can optionally include following details.
- queryString
- specific header value
- specific request parameter value
Example cacheKeyFormats
- "queryString"
- "header=Content-Type, header=Vary"
- "parameter=format, parameter=id, header=Vary"
@param request HttpServletRequest
@return key generated Cache key as per the rule | [
"Generate",
"the",
"cache",
"key",
"for",
"the",
"specific",
"request",
"by",
"using",
"the",
"cacheKeyFormat",
"init",
"param",
"You",
"can",
"specify",
"comma",
"separated",
"list",
"of",
"attributes",
"that",
"you",
"want",
"to",
"use",
"to",
"build",
"th... | fdd04f59923cd0f2d80540b861aa0268da99f5c7 | https://github.com/rpatil26/webutilities/blob/fdd04f59923cd0f2d80540b861aa0268da99f5c7/src/main/java/com/googlecode/webutilities/filters/ResponseCacheFilter.java#L302-L317 | train |
jingwei/krati | krati-main/src/main/java/krati/core/array/basic/AbstractRecoverableArray.java | AbstractRecoverableArray.init | protected void init() throws IOException {
try {
long lwmScn = _arrayFile.getLwmScn();
long hwmScn = _arrayFile.getHwmScn();
if (hwmScn < lwmScn) {
throw new IOException(_arrayFile.getAbsolutePath() + " is corrupted: lwmScn=" + lwmScn + " hwmScn=" + hwmScn);
}
// Initialize entry manager and process entry files on disk if any.
_entryManager.init(lwmScn, hwmScn);
// Load data from the array file on disk.
loadArrayFileData();
} catch (IOException e) {
_entryManager.clear();
getLogger().error(e.getMessage(), e);
throw e;
}
} | java | protected void init() throws IOException {
try {
long lwmScn = _arrayFile.getLwmScn();
long hwmScn = _arrayFile.getHwmScn();
if (hwmScn < lwmScn) {
throw new IOException(_arrayFile.getAbsolutePath() + " is corrupted: lwmScn=" + lwmScn + " hwmScn=" + hwmScn);
}
// Initialize entry manager and process entry files on disk if any.
_entryManager.init(lwmScn, hwmScn);
// Load data from the array file on disk.
loadArrayFileData();
} catch (IOException e) {
_entryManager.clear();
getLogger().error(e.getMessage(), e);
throw e;
}
} | [
"protected",
"void",
"init",
"(",
")",
"throws",
"IOException",
"{",
"try",
"{",
"long",
"lwmScn",
"=",
"_arrayFile",
".",
"getLwmScn",
"(",
")",
";",
"long",
"hwmScn",
"=",
"_arrayFile",
".",
"getHwmScn",
"(",
")",
";",
"if",
"(",
"hwmScn",
"<",
"lwmS... | Loads data from the array file. | [
"Loads",
"data",
"from",
"the",
"array",
"file",
"."
] | 1ca0f994a7b0c8215b827eac9aaf95789ec08d21 | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/core/array/basic/AbstractRecoverableArray.java#L105-L123 | train |
oehf/ipf-oht-atna | nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/utils/AliasSensitiveX509KeyManager.java | AliasSensitiveX509KeyManager.chooseClientAliasForKey | private String chooseClientAliasForKey(String preferredAlias, String keyType, Principal[] issuers, Socket socket)
{
String[] aliases = getClientAliases(keyType, issuers);
if (aliases != null && aliases.length > 0) {
for (int i=0; i<aliases.length;i++) {
if (preferredAlias.equals(aliases[i])) {
return aliases[i];
}
}
}
return null;
} | java | private String chooseClientAliasForKey(String preferredAlias, String keyType, Principal[] issuers, Socket socket)
{
String[] aliases = getClientAliases(keyType, issuers);
if (aliases != null && aliases.length > 0) {
for (int i=0; i<aliases.length;i++) {
if (preferredAlias.equals(aliases[i])) {
return aliases[i];
}
}
}
return null;
} | [
"private",
"String",
"chooseClientAliasForKey",
"(",
"String",
"preferredAlias",
",",
"String",
"keyType",
",",
"Principal",
"[",
"]",
"issuers",
",",
"Socket",
"socket",
")",
"{",
"String",
"[",
"]",
"aliases",
"=",
"getClientAliases",
"(",
"keyType",
",",
"i... | Attempts to find a keystore
@param keyType
@param issuers
@param socket
@return | [
"Attempts",
"to",
"find",
"a",
"keystore"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/utils/AliasSensitiveX509KeyManager.java#L142-L154 | train |
rpatil26/webutilities | src/main/java/com/googlecode/webutilities/util/Utils.java | Utils.simpleHashOf | private static String simpleHashOf(String resourceRealPath) {
if (resourceRealPath == null) return null;
File resource = new File(resourceRealPath);
if (!resource.exists()) return null;
long lastModified = resource.lastModified();
long size = resource.length();
return String.format("%s#%s", lastModified, size);
} | java | private static String simpleHashOf(String resourceRealPath) {
if (resourceRealPath == null) return null;
File resource = new File(resourceRealPath);
if (!resource.exists()) return null;
long lastModified = resource.lastModified();
long size = resource.length();
return String.format("%s#%s", lastModified, size);
} | [
"private",
"static",
"String",
"simpleHashOf",
"(",
"String",
"resourceRealPath",
")",
"{",
"if",
"(",
"resourceRealPath",
"==",
"null",
")",
"return",
"null",
";",
"File",
"resource",
"=",
"new",
"File",
"(",
"resourceRealPath",
")",
";",
"if",
"(",
"!",
... | Calculates simple hash using file size and last modified time.
@param resourceRealPath - file path, whose has to be calculated
@return - hash string as lastmodified#size | [
"Calculates",
"simple",
"hash",
"using",
"file",
"size",
"and",
"last",
"modified",
"time",
"."
] | fdd04f59923cd0f2d80540b861aa0268da99f5c7 | https://github.com/rpatil26/webutilities/blob/fdd04f59923cd0f2d80540b861aa0268da99f5c7/src/main/java/com/googlecode/webutilities/util/Utils.java#L190-L197 | train |
rpatil26/webutilities | src/main/java/com/googlecode/webutilities/util/Utils.java | Utils.getParentPath | public static String getParentPath(String path) {
if (path == null) return null;
path = path.trim();
if (path.endsWith(PATH_ROOT) && path.length() > 1) {
path = path.substring(0, path.length() - 1);
}
int lastIndex = path.lastIndexOf(PATH_ROOT);
if (path.length() > 1 && lastIndex > 0) {
return path.substring(0, lastIndex);
}
return PATH_ROOT;
} | java | public static String getParentPath(String path) {
if (path == null) return null;
path = path.trim();
if (path.endsWith(PATH_ROOT) && path.length() > 1) {
path = path.substring(0, path.length() - 1);
}
int lastIndex = path.lastIndexOf(PATH_ROOT);
if (path.length() > 1 && lastIndex > 0) {
return path.substring(0, lastIndex);
}
return PATH_ROOT;
} | [
"public",
"static",
"String",
"getParentPath",
"(",
"String",
"path",
")",
"{",
"if",
"(",
"path",
"==",
"null",
")",
"return",
"null",
";",
"path",
"=",
"path",
".",
"trim",
"(",
")",
";",
"if",
"(",
"path",
".",
"endsWith",
"(",
"PATH_ROOT",
")",
... | Fast get parent directory using substring
@param path path whose parent path has to be returned
@return parent path of the argument | [
"Fast",
"get",
"parent",
"directory",
"using",
"substring"
] | fdd04f59923cd0f2d80540b861aa0268da99f5c7 | https://github.com/rpatil26/webutilities/blob/fdd04f59923cd0f2d80540b861aa0268da99f5c7/src/main/java/com/googlecode/webutilities/util/Utils.java#L503-L514 | train |
oehf/ipf-oht-atna | nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/handlers/AbstractSecureSocketHandler.java | AbstractSecureSocketHandler.createSocket | protected Socket createSocket(String host, int port) throws SocketException, UnknownHostException
{
Socket socket = null;
int retries = 0;
// Loop to get a connection or until we've exhausted number of retries
Throwable cause = null;
while (retries < CONTEXT.getConfig().getSocketRetries()) {
try {
socket = createSocketFromFactory(SocketFactory.getDefault(), host, port);
break;
} catch (UnknownHostException e) {
logger.error("Unknown host. Unable to establish connection to " + host + " on port "+ port +". Reason: "+e.getLocalizedMessage(),e);
throw e;
} catch (SocketException e) {
// Some kind of error, retry if we haven't exceeded max retry
// count
logger.error("Error connecting to " + host + " on port "+ port +". Will retry in " + CONTEXT.getConfig().getSocketRetryWait() / 1000 + " seconds. "
+ (CONTEXT.getConfig().getSocketRetries() - retries) +" retries left. Cause: "+e.getLocalizedMessage(),e);
cause = e;
retries++;
try {
Thread.sleep(CONTEXT.getConfig().getSocketRetryWait());
continue;
} catch (InterruptedException ie) {
if(logger.isDebugEnabled()){
logger.debug("Sleep awoken early");
}
continue;
}
} catch (IOException e) {
// Some kind of error, retry if we haven't exceeded max retry
// count
logger.error("Error connecting to " + host + " on port "+ port +". Will retry in "
+ CONTEXT.getConfig().getSocketRetryWait() / 1000 + " seconds. "
+ (CONTEXT.getConfig().getSocketRetries() - retries) +" retries left. Cause: "+e.getLocalizedMessage(),e);
retries++;
cause = e;
continue;
}
}
if (retries >= CONTEXT.getConfig().getSocketRetries()) {
logger.error("Socket Connect Retries Exhausted.", cause);
throw new ConnectException("Socket Connect Retries Exhausted. "+ (cause != null ? "Cause was: "+cause.getLocalizedMessage():""));
}
return socket;
} | java | protected Socket createSocket(String host, int port) throws SocketException, UnknownHostException
{
Socket socket = null;
int retries = 0;
// Loop to get a connection or until we've exhausted number of retries
Throwable cause = null;
while (retries < CONTEXT.getConfig().getSocketRetries()) {
try {
socket = createSocketFromFactory(SocketFactory.getDefault(), host, port);
break;
} catch (UnknownHostException e) {
logger.error("Unknown host. Unable to establish connection to " + host + " on port "+ port +". Reason: "+e.getLocalizedMessage(),e);
throw e;
} catch (SocketException e) {
// Some kind of error, retry if we haven't exceeded max retry
// count
logger.error("Error connecting to " + host + " on port "+ port +". Will retry in " + CONTEXT.getConfig().getSocketRetryWait() / 1000 + " seconds. "
+ (CONTEXT.getConfig().getSocketRetries() - retries) +" retries left. Cause: "+e.getLocalizedMessage(),e);
cause = e;
retries++;
try {
Thread.sleep(CONTEXT.getConfig().getSocketRetryWait());
continue;
} catch (InterruptedException ie) {
if(logger.isDebugEnabled()){
logger.debug("Sleep awoken early");
}
continue;
}
} catch (IOException e) {
// Some kind of error, retry if we haven't exceeded max retry
// count
logger.error("Error connecting to " + host + " on port "+ port +". Will retry in "
+ CONTEXT.getConfig().getSocketRetryWait() / 1000 + " seconds. "
+ (CONTEXT.getConfig().getSocketRetries() - retries) +" retries left. Cause: "+e.getLocalizedMessage(),e);
retries++;
cause = e;
continue;
}
}
if (retries >= CONTEXT.getConfig().getSocketRetries()) {
logger.error("Socket Connect Retries Exhausted.", cause);
throw new ConnectException("Socket Connect Retries Exhausted. "+ (cause != null ? "Cause was: "+cause.getLocalizedMessage():""));
}
return socket;
} | [
"protected",
"Socket",
"createSocket",
"(",
"String",
"host",
",",
"int",
"port",
")",
"throws",
"SocketException",
",",
"UnknownHostException",
"{",
"Socket",
"socket",
"=",
"null",
";",
"int",
"retries",
"=",
"0",
";",
"// Loop to get a connection or until we've e... | Create non-secure socket for a given URI.
@param host host to connect to
@param port port to connect to
@return socket
@throws SocketException
@throws UnknownHostException
@throws Exception | [
"Create",
"non",
"-",
"secure",
"socket",
"for",
"a",
"given",
"URI",
"."
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/handlers/AbstractSecureSocketHandler.java#L160-L214 | train |
oehf/ipf-oht-atna | nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/handlers/AbstractSecureSocketHandler.java | AbstractSecureSocketHandler.createSocketFromFactory | protected Socket createSocketFromFactory(SocketFactory factory, String host, int port) throws IOException
{
if (logger.isDebugEnabled()) {
logger.debug("Connecting to " + host +" on port " + port +
" (timeout: " + CONTEXT.getConfig().getConnectTimeout() + " ms) using factory "+ factory.getClass().getName());
}
SocketAddress address = new InetSocketAddress(host,port);
Socket socket = factory.createSocket();
socket.connect(address, CONTEXT.getConfig().getConnectTimeout());
// Set amount of time to wait on socket read before timing out
socket.setSoTimeout(CONTEXT.getConfig().getSocketTimeout());
socket.setKeepAlive(true);
return socket;
} | java | protected Socket createSocketFromFactory(SocketFactory factory, String host, int port) throws IOException
{
if (logger.isDebugEnabled()) {
logger.debug("Connecting to " + host +" on port " + port +
" (timeout: " + CONTEXT.getConfig().getConnectTimeout() + " ms) using factory "+ factory.getClass().getName());
}
SocketAddress address = new InetSocketAddress(host,port);
Socket socket = factory.createSocket();
socket.connect(address, CONTEXT.getConfig().getConnectTimeout());
// Set amount of time to wait on socket read before timing out
socket.setSoTimeout(CONTEXT.getConfig().getSocketTimeout());
socket.setKeepAlive(true);
return socket;
} | [
"protected",
"Socket",
"createSocketFromFactory",
"(",
"SocketFactory",
"factory",
",",
"String",
"host",
",",
"int",
"port",
")",
"throws",
"IOException",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"C... | Creates a new connected socket to a given host and port from a provided Socket Factory.
@param factory Java Socket Factory to use in the connection
@param host Hostname to connect to
@param port Port to connect to
@return Connected socket instance from the given factory
@throws IOException | [
"Creates",
"a",
"new",
"connected",
"socket",
"to",
"a",
"given",
"host",
"and",
"port",
"from",
"a",
"provided",
"Socket",
"Factory",
"."
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/handlers/AbstractSecureSocketHandler.java#L224-L238 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/antlr/AbstractCobolSourceCleaner.java | AbstractCobolSourceCleaner.isLineOfCode | public boolean isLineOfCode(final String line) {
if (line.length() < getIndicatorAreaPos() + 1) {
return false;
}
/* Remove white space lines */
if (line.trim().length() == 0) {
return false;
}
/* Remove comments and special lines */
if (isComment(line)) {
return false;
}
/*
* If there is a single token on this line, make sure it is not a
* compiler directive.
*/
String[] tokens = line.trim().split("[\\s\\.]+");
if (tokens.length == 1
&& COMPILER_DIRECTIVES.contains(tokens[0].toUpperCase(Locale
.getDefault()))) {
return false;
}
return true;
} | java | public boolean isLineOfCode(final String line) {
if (line.length() < getIndicatorAreaPos() + 1) {
return false;
}
/* Remove white space lines */
if (line.trim().length() == 0) {
return false;
}
/* Remove comments and special lines */
if (isComment(line)) {
return false;
}
/*
* If there is a single token on this line, make sure it is not a
* compiler directive.
*/
String[] tokens = line.trim().split("[\\s\\.]+");
if (tokens.length == 1
&& COMPILER_DIRECTIVES.contains(tokens[0].toUpperCase(Locale
.getDefault()))) {
return false;
}
return true;
} | [
"public",
"boolean",
"isLineOfCode",
"(",
"final",
"String",
"line",
")",
"{",
"if",
"(",
"line",
".",
"length",
"(",
")",
"<",
"getIndicatorAreaPos",
"(",
")",
"+",
"1",
")",
"{",
"return",
"false",
";",
"}",
"/* Remove white space lines */",
"if",
"(",
... | Make sure this is a line worth parsing. Ignore empty lines, comments and
compiler directives.
@param line the line to parse
@return true if this is not an empty or comment line | [
"Make",
"sure",
"this",
"is",
"a",
"line",
"worth",
"parsing",
".",
"Ignore",
"empty",
"lines",
"comments",
"and",
"compiler",
"directives",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/antlr/AbstractCobolSourceCleaner.java#L130-L157 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/antlr/AbstractCobolSourceCleaner.java | AbstractCobolSourceCleaner.cleanLine | public String cleanLine(final String line) {
String cleanedLine = extendedCleanLine(line);
/* Right trim, no need to over burden the lexer with spaces */
cleanedLine = ("a" + cleanedLine).trim().substring(1);
return cleanedLine;
} | java | public String cleanLine(final String line) {
String cleanedLine = extendedCleanLine(line);
/* Right trim, no need to over burden the lexer with spaces */
cleanedLine = ("a" + cleanedLine).trim().substring(1);
return cleanedLine;
} | [
"public",
"String",
"cleanLine",
"(",
"final",
"String",
"line",
")",
"{",
"String",
"cleanedLine",
"=",
"extendedCleanLine",
"(",
"line",
")",
";",
"/* Right trim, no need to over burden the lexer with spaces */",
"cleanedLine",
"=",
"(",
"\"a\"",
"+",
"cleanedLine",
... | Remove characters that should not be passed to the lexer.
@param line before cleaning
@return a cleaner line of code | [
"Remove",
"characters",
"that",
"should",
"not",
"be",
"passed",
"to",
"the",
"lexer",
"."
] | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/antlr/AbstractCobolSourceCleaner.java#L165-L172 | train |
legsem/legstar-core2 | legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/antlr/AbstractCobolSourceCleaner.java | AbstractCobolSourceCleaner.isArgument | protected boolean isArgument(final String fragment) {
String s = fragment.trim();
if (s.length() > 0) {
return s.charAt(s.length() - 1) != COBOL_DELIMITER;
}
return false;
} | java | protected boolean isArgument(final String fragment) {
String s = fragment.trim();
if (s.length() > 0) {
return s.charAt(s.length() - 1) != COBOL_DELIMITER;
}
return false;
} | [
"protected",
"boolean",
"isArgument",
"(",
"final",
"String",
"fragment",
")",
"{",
"String",
"s",
"=",
"fragment",
".",
"trim",
"(",
")",
";",
"if",
"(",
"s",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"return",
"s",
".",
"charAt",
"(",
"s",
"... | Examine characters before an assumed level. If these characters are not
terminated by a COBOL delimiter then the level is actually an argument to
a previous keyword, not an actual level.
@param fragment a fragment of code preceding an assumed level
@return true if the assumed level is an argument | [
"Examine",
"characters",
"before",
"an",
"assumed",
"level",
".",
"If",
"these",
"characters",
"are",
"not",
"terminated",
"by",
"a",
"COBOL",
"delimiter",
"then",
"the",
"level",
"is",
"actually",
"an",
"argument",
"to",
"a",
"previous",
"keyword",
"not",
"... | f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6 | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-cob2xsd/src/main/java/com/legstar/cob2xsd/antlr/AbstractCobolSourceCleaner.java#L506-L512 | train |
apptik/jus | android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java | ImageLoader.getImageListener | public static ImageListener getImageListener(final ImageView view,
final int defaultImageResId, final int errorImageResId) {
return new ImageListener() {
@Override
public void onError(JusError error) {
if (errorImageResId != 0) {
view.setImageResource(errorImageResId);
}
}
@Override
public void onResponse(ImageContainer response, boolean isImmediate) {
if (response.getBitmap() != null) {
view.setImageBitmap(response.getBitmap());
} else if (defaultImageResId != 0) {
view.setImageResource(defaultImageResId);
}
}
};
} | java | public static ImageListener getImageListener(final ImageView view,
final int defaultImageResId, final int errorImageResId) {
return new ImageListener() {
@Override
public void onError(JusError error) {
if (errorImageResId != 0) {
view.setImageResource(errorImageResId);
}
}
@Override
public void onResponse(ImageContainer response, boolean isImmediate) {
if (response.getBitmap() != null) {
view.setImageBitmap(response.getBitmap());
} else if (defaultImageResId != 0) {
view.setImageResource(defaultImageResId);
}
}
};
} | [
"public",
"static",
"ImageListener",
"getImageListener",
"(",
"final",
"ImageView",
"view",
",",
"final",
"int",
"defaultImageResId",
",",
"final",
"int",
"errorImageResId",
")",
"{",
"return",
"new",
"ImageListener",
"(",
")",
"{",
"@",
"Override",
"public",
"v... | The default implementation of ImageListener which handles basic functionality
of showing a default image until the network response is received, at which point
it will switch to either the actual image or the error image.
@param view The imageView that the listener is associated with.
@param defaultImageResId Default image resource ID to use, or 0 if it doesn't exist.
@param errorImageResId Error image resource ID to use, or 0 if it doesn't exist. | [
"The",
"default",
"implementation",
"of",
"ImageListener",
"which",
"handles",
"basic",
"functionality",
"of",
"showing",
"a",
"default",
"image",
"until",
"the",
"network",
"response",
"is",
"received",
"at",
"which",
"point",
"it",
"will",
"switch",
"to",
"eit... | 8a37a21b41f897d68eaeaab07368ec22a1e5a60e | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java#L153-L172 | train |
apptik/jus | android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java | ImageLoader.get | public ImageContainer get(String requestUrl, final ImageListener listener, final Object tag) {
return get(requestUrl, listener, 0, 0, tag);
} | java | public ImageContainer get(String requestUrl, final ImageListener listener, final Object tag) {
return get(requestUrl, listener, 0, 0, tag);
} | [
"public",
"ImageContainer",
"get",
"(",
"String",
"requestUrl",
",",
"final",
"ImageListener",
"listener",
",",
"final",
"Object",
"tag",
")",
"{",
"return",
"get",
"(",
"requestUrl",
",",
"listener",
",",
"0",
",",
"0",
",",
"tag",
")",
";",
"}"
] | Returns an ImageContainer for the requested URL.
The ImageContainer will contain either the specified default bitmap or the loaded bitmap.
If the default was returned, the {@link ImageLoader} will be invoked when the
request is fulfilled.
@param requestUrl The URL of the image to be loaded. | [
"Returns",
"an",
"ImageContainer",
"for",
"the",
"requested",
"URL",
"."
] | 8a37a21b41f897d68eaeaab07368ec22a1e5a60e | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java#L238-L240 | train |
apptik/jus | android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java | ImageLoader.onGetImageSuccess | protected void onGetImageSuccess(String cacheKey, Bitmap response) {
// cache the image that was fetched.
imageCache.putBitmap(cacheKey, response);
// remove the request from the list of in-flight requests.
BatchedImageRequest request = inFlightRequests.remove(cacheKey);
if (request != null) {
// Update the response bitmap.
request.mResponseBitmap = response;
// Send the batched response
batchResponse(cacheKey, request);
}
} | java | protected void onGetImageSuccess(String cacheKey, Bitmap response) {
// cache the image that was fetched.
imageCache.putBitmap(cacheKey, response);
// remove the request from the list of in-flight requests.
BatchedImageRequest request = inFlightRequests.remove(cacheKey);
if (request != null) {
// Update the response bitmap.
request.mResponseBitmap = response;
// Send the batched response
batchResponse(cacheKey, request);
}
} | [
"protected",
"void",
"onGetImageSuccess",
"(",
"String",
"cacheKey",
",",
"Bitmap",
"response",
")",
"{",
"// cache the image that was fetched.",
"imageCache",
".",
"putBitmap",
"(",
"cacheKey",
",",
"response",
")",
";",
"// remove the request from the list of in-flight re... | Handler for when an image was successfully loaded.
@param cacheKey The cache key that is associated with the image request.
@param response The bitmap that was returned from the network. | [
"Handler",
"for",
"when",
"an",
"image",
"was",
"successfully",
"loaded",
"."
] | 8a37a21b41f897d68eaeaab07368ec22a1e5a60e | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java#L343-L357 | train |
apptik/jus | android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java | ImageLoader.onGetImageError | protected void onGetImageError(String cacheKey, JusError error) {
// Notify the requesters that something failed via a null result.
// Remove this request from the list of in-flight requests.
BatchedImageRequest request = inFlightRequests.remove(cacheKey);
if (request != null) {
// Set the error for this request
request.setError(error);
// Send the batched response
batchResponse(cacheKey, request);
}
} | java | protected void onGetImageError(String cacheKey, JusError error) {
// Notify the requesters that something failed via a null result.
// Remove this request from the list of in-flight requests.
BatchedImageRequest request = inFlightRequests.remove(cacheKey);
if (request != null) {
// Set the error for this request
request.setError(error);
// Send the batched response
batchResponse(cacheKey, request);
}
} | [
"protected",
"void",
"onGetImageError",
"(",
"String",
"cacheKey",
",",
"JusError",
"error",
")",
"{",
"// Notify the requesters that something failed via a null result.",
"// Remove this request from the list of in-flight requests.",
"BatchedImageRequest",
"request",
"=",
"inFlightR... | Handler for when an image failed to load.
@param cacheKey The cache key that is associated with the image request. | [
"Handler",
"for",
"when",
"an",
"image",
"failed",
"to",
"load",
"."
] | 8a37a21b41f897d68eaeaab07368ec22a1e5a60e | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java#L363-L375 | train |
apptik/jus | android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java | ImageLoader.batchResponse | private void batchResponse(String cacheKey, BatchedImageRequest request) {
batchedResponses.put(cacheKey, request);
// If we don't already have a batch delivery runnable in flight, make a new one.
// Note that this will be used to deliver responses to all callers in batchedResponses.
if (runnable == null) {
runnable = new Runnable() {
@Override
public void run() {
for (BatchedImageRequest bir : batchedResponses.values()) {
for (ImageContainer container : bir.mContainers) {
// If one of the callers in the batched request canceled the request
// after the response was received but before it was delivered,
// skip them.
if (container.mListener == null) {
continue;
}
if (bir.getError() == null) {
container.mBitmap = bir.mResponseBitmap;
container.mListener.onResponse(container, false);
} else {
container.mListener.onError(bir.getError());
}
}
}
batchedResponses.clear();
runnable = null;
}
};
// Post the runnable.
handler.postDelayed(runnable, batchResponseDelayMs);
}
} | java | private void batchResponse(String cacheKey, BatchedImageRequest request) {
batchedResponses.put(cacheKey, request);
// If we don't already have a batch delivery runnable in flight, make a new one.
// Note that this will be used to deliver responses to all callers in batchedResponses.
if (runnable == null) {
runnable = new Runnable() {
@Override
public void run() {
for (BatchedImageRequest bir : batchedResponses.values()) {
for (ImageContainer container : bir.mContainers) {
// If one of the callers in the batched request canceled the request
// after the response was received but before it was delivered,
// skip them.
if (container.mListener == null) {
continue;
}
if (bir.getError() == null) {
container.mBitmap = bir.mResponseBitmap;
container.mListener.onResponse(container, false);
} else {
container.mListener.onError(bir.getError());
}
}
}
batchedResponses.clear();
runnable = null;
}
};
// Post the runnable.
handler.postDelayed(runnable, batchResponseDelayMs);
}
} | [
"private",
"void",
"batchResponse",
"(",
"String",
"cacheKey",
",",
"BatchedImageRequest",
"request",
")",
"{",
"batchedResponses",
".",
"put",
"(",
"cacheKey",
",",
"request",
")",
";",
"// If we don't already have a batch delivery runnable in flight, make a new one.",
"//... | Starts the runnable for batched delivery of responses if it is not already started.
@param cacheKey The cacheKey of the response being delivered.
@param request The BatchedImageRequest to be delivered. | [
"Starts",
"the",
"runnable",
"for",
"batched",
"delivery",
"of",
"responses",
"if",
"it",
"is",
"not",
"already",
"started",
"."
] | 8a37a21b41f897d68eaeaab07368ec22a1e5a60e | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java#L520-L552 | train |
apptik/jus | android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java | ImageLoader.getCacheKey | private static String getCacheKey(String url, int maxWidth, int maxHeight, ScaleType scaleType) {
return "#W" + maxWidth + "#H" + maxHeight + "#S" + scaleType.ordinal() + url;
} | java | private static String getCacheKey(String url, int maxWidth, int maxHeight, ScaleType scaleType) {
return "#W" + maxWidth + "#H" + maxHeight + "#S" + scaleType.ordinal() + url;
} | [
"private",
"static",
"String",
"getCacheKey",
"(",
"String",
"url",
",",
"int",
"maxWidth",
",",
"int",
"maxHeight",
",",
"ScaleType",
"scaleType",
")",
"{",
"return",
"\"#W\"",
"+",
"maxWidth",
"+",
"\"#H\"",
"+",
"maxHeight",
"+",
"\"#S\"",
"+",
"scaleType... | Creates a cache key for use with the L1 cache.
@param url The URL of the request.
@param maxWidth The max-width of the output.
@param maxHeight The max-height of the output.
@param scaleType The scaleType of the imageView. | [
"Creates",
"a",
"cache",
"key",
"for",
"use",
"with",
"the",
"L1",
"cache",
"."
] | 8a37a21b41f897d68eaeaab07368ec22a1e5a60e | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java#L567-L569 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSSourceAuditor.java | XDSSourceAuditor.getAuditor | public static XDSSourceAuditor getAuditor()
{
AuditorModuleContext ctx = AuditorModuleContext.getContext();
return (XDSSourceAuditor)ctx.getAuditor(XDSSourceAuditor.class);
} | java | public static XDSSourceAuditor getAuditor()
{
AuditorModuleContext ctx = AuditorModuleContext.getContext();
return (XDSSourceAuditor)ctx.getAuditor(XDSSourceAuditor.class);
} | [
"public",
"static",
"XDSSourceAuditor",
"getAuditor",
"(",
")",
"{",
"AuditorModuleContext",
"ctx",
"=",
"AuditorModuleContext",
".",
"getContext",
"(",
")",
";",
"return",
"(",
"XDSSourceAuditor",
")",
"ctx",
".",
"getAuditor",
"(",
"XDSSourceAuditor",
".",
"clas... | Get an instance of the XDS Document Source Auditor from the
global context
@return XDS Document Source Auditor instance | [
"Get",
"an",
"instance",
"of",
"the",
"XDS",
"Document",
"Source",
"Auditor",
"from",
"the",
"global",
"context"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSSourceAuditor.java#L43-L47 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSSourceAuditor.java | XDSSourceAuditor.auditProvideAndRegisterDocumentSetEvent | public void auditProvideAndRegisterDocumentSetEvent(RFC3881EventOutcomeCodes eventOutcome,
String repositoryEndpointUri,
String userName,
String submissionSetUniqueId,
String patientId)
{
if (!isAuditorEnabled()) {
return;
}
auditProvideAndRegisterEvent( new IHETransactionEventTypeCodes.ProvideAndRegisterDocumentSet(),
eventOutcome, repositoryEndpointUri,
userName,
submissionSetUniqueId, patientId, null, null);
} | java | public void auditProvideAndRegisterDocumentSetEvent(RFC3881EventOutcomeCodes eventOutcome,
String repositoryEndpointUri,
String userName,
String submissionSetUniqueId,
String patientId)
{
if (!isAuditorEnabled()) {
return;
}
auditProvideAndRegisterEvent( new IHETransactionEventTypeCodes.ProvideAndRegisterDocumentSet(),
eventOutcome, repositoryEndpointUri,
userName,
submissionSetUniqueId, patientId, null, null);
} | [
"public",
"void",
"auditProvideAndRegisterDocumentSetEvent",
"(",
"RFC3881EventOutcomeCodes",
"eventOutcome",
",",
"String",
"repositoryEndpointUri",
",",
"String",
"userName",
",",
"String",
"submissionSetUniqueId",
",",
"String",
"patientId",
")",
"{",
"if",
"(",
"!",
... | Audits an ITI-15 Provide And Register Document Set event for XDS.a Document Source actors.
@param eventOutcome The event outcome indicator
@param repositoryEndpointUri The endpoint of the repository in this transaction
@param submissionSetUniqueId The UniqueID of the Submission Set provided
@param patientId The Patient Id that this submission pertains to | [
"Audits",
"an",
"ITI",
"-",
"15",
"Provide",
"And",
"Register",
"Document",
"Set",
"event",
"for",
"XDS",
".",
"a",
"Document",
"Source",
"actors",
"."
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSSourceAuditor.java#L57-L70 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSSourceAuditor.java | XDSSourceAuditor.auditProvideAndRegisterDocumentSetBEvent | public void auditProvideAndRegisterDocumentSetBEvent(RFC3881EventOutcomeCodes eventOutcome,
String repositoryEndpointUri,
String userName,
String submissionSetUniqueId,
String patientId,
List<CodedValueType> purposesOfUse,
List<CodedValueType> userRoles)
{
if (!isAuditorEnabled()) {
return;
}
auditProvideAndRegisterEvent( new IHETransactionEventTypeCodes.ProvideAndRegisterDocumentSetB(),
eventOutcome, repositoryEndpointUri,
userName,
submissionSetUniqueId, patientId, purposesOfUse, userRoles);
} | java | public void auditProvideAndRegisterDocumentSetBEvent(RFC3881EventOutcomeCodes eventOutcome,
String repositoryEndpointUri,
String userName,
String submissionSetUniqueId,
String patientId,
List<CodedValueType> purposesOfUse,
List<CodedValueType> userRoles)
{
if (!isAuditorEnabled()) {
return;
}
auditProvideAndRegisterEvent( new IHETransactionEventTypeCodes.ProvideAndRegisterDocumentSetB(),
eventOutcome, repositoryEndpointUri,
userName,
submissionSetUniqueId, patientId, purposesOfUse, userRoles);
} | [
"public",
"void",
"auditProvideAndRegisterDocumentSetBEvent",
"(",
"RFC3881EventOutcomeCodes",
"eventOutcome",
",",
"String",
"repositoryEndpointUri",
",",
"String",
"userName",
",",
"String",
"submissionSetUniqueId",
",",
"String",
"patientId",
",",
"List",
"<",
"CodedValu... | Audits an ITI-41 Provide And Register Document Set-b event for XDS.b Document Source actors.
@param eventOutcome The event outcome indicator
@param repositoryEndpointUri The endpoint of the repository in this transaction
@param submissionSetUniqueId The UniqueID of the Submission Set provided
@param patientId The Patient Id that this submission pertains to
@param purposesOfUse purpose of use codes (may be taken from XUA token)
@param userRoles roles of the human user (may be taken from XUA token) | [
"Audits",
"an",
"ITI",
"-",
"41",
"Provide",
"And",
"Register",
"Document",
"Set",
"-",
"b",
"event",
"for",
"XDS",
".",
"b",
"Document",
"Source",
"actors",
"."
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSSourceAuditor.java#L82-L97 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSSourceAuditor.java | XDSSourceAuditor.auditProvideAndRegisterEvent | protected void auditProvideAndRegisterEvent(
IHETransactionEventTypeCodes transaction, RFC3881EventOutcomeCodes eventOutcome,
String repositoryEndpointUri,
String userName,
String submissionSetUniqueId,
String patientId,
List<CodedValueType> purposesOfUse,
List<CodedValueType> userRoles)
{
ExportEvent exportEvent = new ExportEvent(true, eventOutcome, transaction, purposesOfUse);
exportEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
/*
* FIXME: Overriding endpoint URI with "anonymous", for now
*/
String replyToUri = "http://www.w3.org/2005/08/addressing/anonymous";
//String replyToUri = getSystemUserId();
exportEvent.addSourceActiveParticipant(replyToUri, getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), true);
if (!EventUtils.isEmptyOrNull(userName)) {
exportEvent.addHumanRequestorActiveParticipant(userName, null, userName, userRoles);
}
exportEvent.addDestinationActiveParticipant(repositoryEndpointUri, null, null, EventUtils.getAddressForUrl(repositoryEndpointUri, false), false);
if (!EventUtils.isEmptyOrNull(patientId)) {
exportEvent.addPatientParticipantObject(patientId);
}
exportEvent.addSubmissionSetParticipantObject(submissionSetUniqueId);
audit(exportEvent);
} | java | protected void auditProvideAndRegisterEvent(
IHETransactionEventTypeCodes transaction, RFC3881EventOutcomeCodes eventOutcome,
String repositoryEndpointUri,
String userName,
String submissionSetUniqueId,
String patientId,
List<CodedValueType> purposesOfUse,
List<CodedValueType> userRoles)
{
ExportEvent exportEvent = new ExportEvent(true, eventOutcome, transaction, purposesOfUse);
exportEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId());
/*
* FIXME: Overriding endpoint URI with "anonymous", for now
*/
String replyToUri = "http://www.w3.org/2005/08/addressing/anonymous";
//String replyToUri = getSystemUserId();
exportEvent.addSourceActiveParticipant(replyToUri, getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), true);
if (!EventUtils.isEmptyOrNull(userName)) {
exportEvent.addHumanRequestorActiveParticipant(userName, null, userName, userRoles);
}
exportEvent.addDestinationActiveParticipant(repositoryEndpointUri, null, null, EventUtils.getAddressForUrl(repositoryEndpointUri, false), false);
if (!EventUtils.isEmptyOrNull(patientId)) {
exportEvent.addPatientParticipantObject(patientId);
}
exportEvent.addSubmissionSetParticipantObject(submissionSetUniqueId);
audit(exportEvent);
} | [
"protected",
"void",
"auditProvideAndRegisterEvent",
"(",
"IHETransactionEventTypeCodes",
"transaction",
",",
"RFC3881EventOutcomeCodes",
"eventOutcome",
",",
"String",
"repositoryEndpointUri",
",",
"String",
"userName",
",",
"String",
"submissionSetUniqueId",
",",
"String",
... | Generically sends audit messages for XDS Document Source Provide And Register Document Set events
@param transaction The specific IHE Transaction (ITI-15 or ITI-41)
@param eventOutcome The event outcome indicator
@param repositoryEndpointUri The endpoint of the repository in this transaction
@param submissionSetUniqueId The UniqueID of the Submission Set provided
@param patientId The Patient Id that this submission pertains to
@param purposesOfUse purpose of use codes (may be taken from XUA token)
@param userRoles roles of the human user (may be taken from XUA token) | [
"Generically",
"sends",
"audit",
"messages",
"for",
"XDS",
"Document",
"Source",
"Provide",
"And",
"Register",
"Document",
"Set",
"events"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSSourceAuditor.java#L110-L138 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/dicom/UserAuthenticationEvent.java | UserAuthenticationEvent.addNodeActiveParticipant | public void addNodeActiveParticipant(String userId, String altUserId, String userName, String networkId)
{
addActiveParticipant(
userId,
altUserId,
userName,
true,
Collections.singletonList(new DICOMActiveParticipantRoleIdCodes.Application()),
networkId);
} | java | public void addNodeActiveParticipant(String userId, String altUserId, String userName, String networkId)
{
addActiveParticipant(
userId,
altUserId,
userName,
true,
Collections.singletonList(new DICOMActiveParticipantRoleIdCodes.Application()),
networkId);
} | [
"public",
"void",
"addNodeActiveParticipant",
"(",
"String",
"userId",
",",
"String",
"altUserId",
",",
"String",
"userName",
",",
"String",
"networkId",
")",
"{",
"addActiveParticipant",
"(",
"userId",
",",
"altUserId",
",",
"userName",
",",
"true",
",",
"Colle... | Adds an Active Participant representing the node that is performing the authentication
@param userId The Active Participant's User ID
@param altUserId The Active Participant's Alternate UserID
@param userName The Active Participant's UserName
@param networkId The Active Participant's Network Access Point ID | [
"Adds",
"an",
"Active",
"Participant",
"representing",
"the",
"node",
"that",
"is",
"performing",
"the",
"authentication"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/dicom/UserAuthenticationEvent.java#L91-L100 | train |
keshrath/Giphy4J | src/main/java/at/mukprojects/giphy4j/util/UrlUtil.java | UrlUtil.buildUrlQuery | public static String buildUrlQuery(String baseUrl, Map<String, String> params) {
if (baseUrl.isEmpty() || params.isEmpty()) {
return baseUrl;
} else {
String query = baseUrl;
query += QUERY_STRING_SEPARATOR;
for (String key : params.keySet()) {
query += key;
query += PAIR_SEPARATOR;
query += encodeString(params.get(key));
query += PARAM_SEPARATOR;
}
return query.substring(0, query.length() - 1);
}
} | java | public static String buildUrlQuery(String baseUrl, Map<String, String> params) {
if (baseUrl.isEmpty() || params.isEmpty()) {
return baseUrl;
} else {
String query = baseUrl;
query += QUERY_STRING_SEPARATOR;
for (String key : params.keySet()) {
query += key;
query += PAIR_SEPARATOR;
query += encodeString(params.get(key));
query += PARAM_SEPARATOR;
}
return query.substring(0, query.length() - 1);
}
} | [
"public",
"static",
"String",
"buildUrlQuery",
"(",
"String",
"baseUrl",
",",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"{",
"if",
"(",
"baseUrl",
".",
"isEmpty",
"(",
")",
"||",
"params",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
... | Builds the URL String.
@param baseUrl
the base URL.
@param params
the URL parameter.
@return the URL as String. | [
"Builds",
"the",
"URL",
"String",
"."
] | e56b67f161e2184ccff9b9e8f95a70ef89cec897 | https://github.com/keshrath/Giphy4J/blob/e56b67f161e2184ccff9b9e8f95a70ef89cec897/src/main/java/at/mukprojects/giphy4j/util/UrlUtil.java#L48-L64 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java | AbstractAuditEventMessageImpl.setAuditMessageElements | protected void setAuditMessageElements(EventIdentificationType eventId, ActiveParticipantType[] participants,
AuditSourceIdentificationType[] sourceIds, ParticipantObjectIdentificationType[] objectIds) {
AuditMessage auditMessage = getAuditMessage();
auditMessage.setEventIdentification(eventId);
// Reset active participants
auditMessage.getActiveParticipant().clear();
if (!EventUtils.isEmptyOrNull(participants, true)) {
auditMessage.getActiveParticipant().addAll(Arrays.asList(participants));
}
// reset audit source ids
auditMessage.getAuditSourceIdentification().clear();
if (!EventUtils.isEmptyOrNull(sourceIds, true)) {
auditMessage.getAuditSourceIdentification().addAll(Arrays.asList(sourceIds));
}
// Reset participant object ids
auditMessage.getParticipantObjectIdentification().clear();
if (!EventUtils.isEmptyOrNull(objectIds, true)) {
auditMessage.getParticipantObjectIdentification().addAll(Arrays.asList(objectIds));
}
} | java | protected void setAuditMessageElements(EventIdentificationType eventId, ActiveParticipantType[] participants,
AuditSourceIdentificationType[] sourceIds, ParticipantObjectIdentificationType[] objectIds) {
AuditMessage auditMessage = getAuditMessage();
auditMessage.setEventIdentification(eventId);
// Reset active participants
auditMessage.getActiveParticipant().clear();
if (!EventUtils.isEmptyOrNull(participants, true)) {
auditMessage.getActiveParticipant().addAll(Arrays.asList(participants));
}
// reset audit source ids
auditMessage.getAuditSourceIdentification().clear();
if (!EventUtils.isEmptyOrNull(sourceIds, true)) {
auditMessage.getAuditSourceIdentification().addAll(Arrays.asList(sourceIds));
}
// Reset participant object ids
auditMessage.getParticipantObjectIdentification().clear();
if (!EventUtils.isEmptyOrNull(objectIds, true)) {
auditMessage.getParticipantObjectIdentification().addAll(Arrays.asList(objectIds));
}
} | [
"protected",
"void",
"setAuditMessageElements",
"(",
"EventIdentificationType",
"eventId",
",",
"ActiveParticipantType",
"[",
"]",
"participants",
",",
"AuditSourceIdentificationType",
"[",
"]",
"sourceIds",
",",
"ParticipantObjectIdentificationType",
"[",
"]",
"objectIds",
... | Clear and set the individual elements of the audit message payload
in line with RFC 3881
@param eventId The EventIdentification block
@param participants The ActiveParticipant blocks
@param sourceIds The AuditSourceIdentification blocks
@param objectIds The ParticipantObjectIdentification blocks | [
"Clear",
"and",
"set",
"the",
"individual",
"elements",
"of",
"the",
"audit",
"message",
"payload",
"in",
"line",
"with",
"RFC",
"3881"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java#L197-L219 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java | AbstractAuditEventMessageImpl.setEventIdentification | protected EventIdentificationType setEventIdentification(
RFC3881EventOutcomeCodes outcome,
RFC3881EventActionCodes action,
CodedValueType id, CodedValueType[] type,
List<CodedValueType> purposesOfUse) {
EventIdentificationType eventBlock = new EventIdentificationType();
eventBlock.setEventID(id);
eventBlock.setEventDateTime(TimestampUtils.getRFC3881Timestamp(eventDateTime));
if (!EventUtils.isEmptyOrNull(action)) {
eventBlock.setEventActionCode(action.getCode());
}
if (!EventUtils.isEmptyOrNull(outcome)) {
eventBlock.setEventOutcomeIndicator(outcome.getCode());
}
if (!EventUtils.isEmptyOrNull(type, true)) {
eventBlock.getEventTypeCode().addAll(Arrays.asList(type));
}
eventBlock.setPurposesOfUse(purposesOfUse);
getAuditMessage().setEventIdentification(eventBlock);
return eventBlock;
} | java | protected EventIdentificationType setEventIdentification(
RFC3881EventOutcomeCodes outcome,
RFC3881EventActionCodes action,
CodedValueType id, CodedValueType[] type,
List<CodedValueType> purposesOfUse) {
EventIdentificationType eventBlock = new EventIdentificationType();
eventBlock.setEventID(id);
eventBlock.setEventDateTime(TimestampUtils.getRFC3881Timestamp(eventDateTime));
if (!EventUtils.isEmptyOrNull(action)) {
eventBlock.setEventActionCode(action.getCode());
}
if (!EventUtils.isEmptyOrNull(outcome)) {
eventBlock.setEventOutcomeIndicator(outcome.getCode());
}
if (!EventUtils.isEmptyOrNull(type, true)) {
eventBlock.getEventTypeCode().addAll(Arrays.asList(type));
}
eventBlock.setPurposesOfUse(purposesOfUse);
getAuditMessage().setEventIdentification(eventBlock);
return eventBlock;
} | [
"protected",
"EventIdentificationType",
"setEventIdentification",
"(",
"RFC3881EventOutcomeCodes",
"outcome",
",",
"RFC3881EventActionCodes",
"action",
",",
"CodedValueType",
"id",
",",
"CodedValueType",
"[",
"]",
"type",
",",
"List",
"<",
"CodedValueType",
">",
"purposes... | Create and set an Event Identification block for this audit event message
@param outcome The Event Outcome Indicator
@param action The Event Action Code
@param id The Event ID
@param type The Event Type Code
@return The Event Identification block created | [
"Create",
"and",
"set",
"an",
"Event",
"Identification",
"block",
"for",
"this",
"audit",
"event",
"message"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java#L230-L253 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java | AbstractAuditEventMessageImpl.addActiveParticipant | protected ActiveParticipantType addActiveParticipant(String userID, String altUserID, String userName,
Boolean userIsRequestor, List<CodedValueType> roleIdCodes, String networkAccessPointID, RFC3881NetworkAccessPointTypeCodes networkAccessPointTypeCode) {
ActiveParticipantType activeParticipantBlock = new ActiveParticipantType();
activeParticipantBlock.setUserID(userID);
activeParticipantBlock.setAlternativeUserID(altUserID);
activeParticipantBlock.setUserName(userName);
activeParticipantBlock.setUserIsRequestor(userIsRequestor);
if (!EventUtils.isEmptyOrNull(roleIdCodes, true)) {
activeParticipantBlock.getRoleIDCode().addAll(roleIdCodes);
}
activeParticipantBlock.setNetworkAccessPointID(networkAccessPointID);
if (!EventUtils.isEmptyOrNull(networkAccessPointTypeCode)) {
activeParticipantBlock.setNetworkAccessPointTypeCode(networkAccessPointTypeCode.getCode());
}
getAuditMessage().getActiveParticipant().add(activeParticipantBlock);
return activeParticipantBlock;
} | java | protected ActiveParticipantType addActiveParticipant(String userID, String altUserID, String userName,
Boolean userIsRequestor, List<CodedValueType> roleIdCodes, String networkAccessPointID, RFC3881NetworkAccessPointTypeCodes networkAccessPointTypeCode) {
ActiveParticipantType activeParticipantBlock = new ActiveParticipantType();
activeParticipantBlock.setUserID(userID);
activeParticipantBlock.setAlternativeUserID(altUserID);
activeParticipantBlock.setUserName(userName);
activeParticipantBlock.setUserIsRequestor(userIsRequestor);
if (!EventUtils.isEmptyOrNull(roleIdCodes, true)) {
activeParticipantBlock.getRoleIDCode().addAll(roleIdCodes);
}
activeParticipantBlock.setNetworkAccessPointID(networkAccessPointID);
if (!EventUtils.isEmptyOrNull(networkAccessPointTypeCode)) {
activeParticipantBlock.setNetworkAccessPointTypeCode(networkAccessPointTypeCode.getCode());
}
getAuditMessage().getActiveParticipant().add(activeParticipantBlock);
return activeParticipantBlock;
} | [
"protected",
"ActiveParticipantType",
"addActiveParticipant",
"(",
"String",
"userID",
",",
"String",
"altUserID",
",",
"String",
"userName",
",",
"Boolean",
"userIsRequestor",
",",
"List",
"<",
"CodedValueType",
">",
"roleIdCodes",
",",
"String",
"networkAccessPointID"... | Create and add an Active Participant block to this audit event message
@param userID The Active Participant's UserID
@param altUserID The Active Participant's Alternate UserID
@param userName The Active Participant's UserName
@param userIsRequestor Whether this Active Participant is a requestor
@param roleIdCodes The Active Participant's Role Codes
@param networkAccessPointID The Active Participant's Network Access Point ID (IP / Hostname)
@param networkAccessPointTypeCode The type code for the Network Access Point ID
@return The Active Participant block created | [
"Create",
"and",
"add",
"an",
"Active",
"Participant",
"block",
"to",
"this",
"audit",
"event",
"message"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java#L267-L286 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java | AbstractAuditEventMessageImpl.addAuditSourceIdentification | protected AuditSourceIdentificationType addAuditSourceIdentification(String sourceID,
String enterpriseSiteID,
RFC3881AuditSourceTypeCodes... typeCodes) {
AuditSourceIdentificationType sourceBlock = new AuditSourceIdentificationType();
if (!EventUtils.isEmptyOrNull(typeCodes, true)) {
sourceBlock.setAuditSourceTypeCode(typeCodes[0]);
}
sourceBlock.setAuditSourceID(sourceID);
sourceBlock.setAuditEnterpriseSiteID(enterpriseSiteID);
getAuditMessage().getAuditSourceIdentification().add(sourceBlock);
return sourceBlock;
} | java | protected AuditSourceIdentificationType addAuditSourceIdentification(String sourceID,
String enterpriseSiteID,
RFC3881AuditSourceTypeCodes... typeCodes) {
AuditSourceIdentificationType sourceBlock = new AuditSourceIdentificationType();
if (!EventUtils.isEmptyOrNull(typeCodes, true)) {
sourceBlock.setAuditSourceTypeCode(typeCodes[0]);
}
sourceBlock.setAuditSourceID(sourceID);
sourceBlock.setAuditEnterpriseSiteID(enterpriseSiteID);
getAuditMessage().getAuditSourceIdentification().add(sourceBlock);
return sourceBlock;
} | [
"protected",
"AuditSourceIdentificationType",
"addAuditSourceIdentification",
"(",
"String",
"sourceID",
",",
"String",
"enterpriseSiteID",
",",
"RFC3881AuditSourceTypeCodes",
"...",
"typeCodes",
")",
"{",
"AuditSourceIdentificationType",
"sourceBlock",
"=",
"new",
"AuditSource... | Create and add an Audit Source Identification block to this audit event message
@param sourceID The Audit Source ID
@param enterpriseSiteID The Audit Enterprise Site ID
@param typeCodes The Audit Source Type Codes
@return The Audit Source Identification block created
@deprecated use {@link #addAuditSourceIdentification(String, String, RFC3881AuditSourceTypes...)} | [
"Create",
"and",
"add",
"an",
"Audit",
"Source",
"Identification",
"block",
"to",
"this",
"audit",
"event",
"message"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java#L298-L312 | train |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java | AbstractAuditEventMessageImpl.addParticipantObjectIdentification | public ParticipantObjectIdentificationType addParticipantObjectIdentification(CodedValueType objectIDTypeCode,
String objectName, byte[] objectQuery, List<TypeValuePairType> objectDetail,
String objectID,
RFC3881ParticipantObjectTypeCodes objectTypeCode,
RFC3881ParticipantObjectTypeRoleCodes objectTypeCodeRole,
RFC3881ParticipantObjectDataLifeCycleCodes objectDataLifeCycle,
String objectSensitivity) {
ParticipantObjectIdentificationType participantBlock = new ParticipantObjectIdentificationType();
participantBlock.setParticipantObjectIDTypeCode(objectIDTypeCode);
participantBlock.setParticipantObjectName(objectName);
participantBlock.setParticipantObjectQuery(objectQuery);
if (!EventUtils.isEmptyOrNull(objectDetail, true)) {
participantBlock.getParticipantObjectDetail().addAll(objectDetail);
}
participantBlock.setParticipantObjectID(objectID);
if (!EventUtils.isEmptyOrNull(objectTypeCode)) {
participantBlock.setParticipantObjectTypeCode(objectTypeCode.getCode());
}
if (!EventUtils.isEmptyOrNull(objectTypeCodeRole)) {
participantBlock.setParticipantObjectTypeCodeRole(objectTypeCodeRole.getCode());
}
if (!EventUtils.isEmptyOrNull(objectDataLifeCycle)) {
participantBlock.setParticipantObjectDataLifeCycle(objectDataLifeCycle.getCode());
}
participantBlock.setParticipantObjectSensitivity(objectSensitivity);
getAuditMessage().getParticipantObjectIdentification().add(participantBlock);
return participantBlock;
} | java | public ParticipantObjectIdentificationType addParticipantObjectIdentification(CodedValueType objectIDTypeCode,
String objectName, byte[] objectQuery, List<TypeValuePairType> objectDetail,
String objectID,
RFC3881ParticipantObjectTypeCodes objectTypeCode,
RFC3881ParticipantObjectTypeRoleCodes objectTypeCodeRole,
RFC3881ParticipantObjectDataLifeCycleCodes objectDataLifeCycle,
String objectSensitivity) {
ParticipantObjectIdentificationType participantBlock = new ParticipantObjectIdentificationType();
participantBlock.setParticipantObjectIDTypeCode(objectIDTypeCode);
participantBlock.setParticipantObjectName(objectName);
participantBlock.setParticipantObjectQuery(objectQuery);
if (!EventUtils.isEmptyOrNull(objectDetail, true)) {
participantBlock.getParticipantObjectDetail().addAll(objectDetail);
}
participantBlock.setParticipantObjectID(objectID);
if (!EventUtils.isEmptyOrNull(objectTypeCode)) {
participantBlock.setParticipantObjectTypeCode(objectTypeCode.getCode());
}
if (!EventUtils.isEmptyOrNull(objectTypeCodeRole)) {
participantBlock.setParticipantObjectTypeCodeRole(objectTypeCodeRole.getCode());
}
if (!EventUtils.isEmptyOrNull(objectDataLifeCycle)) {
participantBlock.setParticipantObjectDataLifeCycle(objectDataLifeCycle.getCode());
}
participantBlock.setParticipantObjectSensitivity(objectSensitivity);
getAuditMessage().getParticipantObjectIdentification().add(participantBlock);
return participantBlock;
} | [
"public",
"ParticipantObjectIdentificationType",
"addParticipantObjectIdentification",
"(",
"CodedValueType",
"objectIDTypeCode",
",",
"String",
"objectName",
",",
"byte",
"[",
"]",
"objectQuery",
",",
"List",
"<",
"TypeValuePairType",
">",
"objectDetail",
",",
"String",
... | Create and add an Participant Object Identification block to this audit event message
@param objectIDTypeCode The Participant Object ID Type code
@param objectName The Participant Object Name
@param objectQuery The Participant Object Query data
@param objectDetail The Participant Object detail
@param objectID The Participant Object ID
@param objectTypeCode The Participant Object Type Code
@param objectTypeCodeRole The Participant Object Type Code's ROle
@param objectDataLifeCycle The Participant Object Data Life Cycle
@param objectSensitivity The Participant Object sensitivity
@return The Participant Object Identification block created | [
"Create",
"and",
"add",
"an",
"Participant",
"Object",
"Identification",
"block",
"to",
"this",
"audit",
"event",
"message"
] | 25ed1e926825169c94923a2c89a4618f60478ae8 | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java#L344-L374 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.