_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q15600 | GA4GHPicardRunner.processGA4GHInput | train | private Input processGA4GHInput(String input) throws IOException, GeneralSecurityException, URISyntaxException {
GA4GHUrl url = new GA4GHUrl(input);
SAMFilePump pump;
if (usingGrpc) {
factoryGrpc.configure(url.getRootUrl(),
new Settings(clientSecretsFilename, apiKey, noLocalServer));
pump = new ReadIteratorToSAMFilePump<
com.google.genomics.v1.Read,
com.google.genomics.v1.ReadGroupSet,
com.google.genomics.v1.Reference>(
factoryGrpc
.get(url.getRootUrl())
.getReads(url));
} else {
factoryRest.configure(url.getRootUrl(),
new Settings(clientSecretsFilename, apiKey, noLocalServer));
pump = new ReadIteratorToSAMFilePump<
com.google.api.services.genomics.model.Read,
com.google.api.services.genomics.model.ReadGroupSet,
com.google.api.services.genomics.model.Reference>(
factoryRest
.get(url.getRootUrl())
.getReads(url));
}
return new Input(input, STDIN_FILE_NAME, pump);
} | java | {
"resource": ""
} |
q15601 | GA4GHPicardRunner.processRegularFileInput | train | private Input processRegularFileInput(String input) throws IOException {
File inputFile = new File(input);
if (!inputFile.exists()) {
throw new IOException("Input does not exist: " + input);
}
if (pipeFiles) {
SamReader samReader = SamReaderFactory.makeDefault().open(inputFile);
return new Input(input, STDIN_FILE_NAME,
new SamReaderToSAMFilePump(samReader));
} else {
return new Input(input, input, null);
}
} | java | {
"resource": ""
} |
q15602 | GA4GHPicardRunner.startProcess | train | private void startProcess() throws IOException {
LOG.info("Building process");
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
LOG.info("Starting process");
process = processBuilder.start();
LOG.info("Process started");
} | java | {
"resource": ""
} |
q15603 | GA4GHPicardRunner.pumpInputData | train | private void pumpInputData() throws IOException {
for (Input input : inputs) {
if (input.pump == null) {
continue;
}
OutputStream os;
if (input.pipeName.equals(STDIN_FILE_NAME)) {
os = process.getOutputStream();
} else {
throw new IOException("Only stdin piping is supported so far.");
}
input.pump.pump(os);
}
} | java | {
"resource": ""
} |
q15604 | NetworkInterfaceHelper.createNetworkInterfaceTree | train | @Nonnull
public static DefaultTreeWithGlobalUniqueID <String, NetworkInterface> createNetworkInterfaceTree ()
{
final DefaultTreeWithGlobalUniqueID <String, NetworkInterface> ret = new DefaultTreeWithGlobalUniqueID <> ();
// Build basic level - all IFs without a parent
final ICommonsList <NetworkInterface> aNonRootNIs = new CommonsArrayList <> ();
try
{
for (final NetworkInterface aNI : IteratorHelper.getIterator (NetworkInterface.getNetworkInterfaces ()))
if (aNI.getParent () == null)
ret.getRootItem ().createChildItem (aNI.getName (), aNI);
else
aNonRootNIs.add (aNI);
}
catch (final Throwable t)
{
throw new IllegalStateException ("Failed to get all network interfaces", t);
}
int nNotFound = 0;
while (aNonRootNIs.isNotEmpty ())
{
final NetworkInterface aNI = aNonRootNIs.removeFirst ();
final DefaultTreeItemWithID <String, NetworkInterface> aParentItem = ret.getItemWithID (aNI.getParent ()
.getName ());
if (aParentItem != null)
{
// We found the parent
aParentItem.createChildItem (aNI.getName (), aNI);
// Reset counter
nNotFound = 0;
}
else
{
// Add again at the end
aNonRootNIs.add (aNI);
// Parent not found
nNotFound++;
// We tried too many times without success - we iterated the whole
// remaining list and found no parent tree item
if (nNotFound > aNonRootNIs.size ())
throw new IllegalStateException ("Seems like we have a data structure inconsistency! Remaining are: " +
aNonRootNIs);
}
}
return ret;
} | java | {
"resource": ""
} |
q15605 | JUnit4Monitor.runnerForClass0 | train | public static Runner runnerForClass0(RunnerBuilder builder, Class<?> testClass) throws Throwable {
if (recursiveDepth > 1 ||
isOnStack(0, CoverageRunner.class.getCanonicalName())) {
return builder.runnerForClass(testClass);
}
AffectingBuilder affectingBuilder = new AffectingBuilder();
Runner runner = affectingBuilder.runnerForClass(testClass);
if (runner != null) {
return runner;
}
CoverageMonitor.clean();
Runner wrapped = builder.runnerForClass(testClass);
return new CoverageRunner(testClass, wrapped, CoverageMonitor.getURLs());
} | java | {
"resource": ""
} |
q15606 | JUnit4Monitor.isOnStack | train | private static boolean isOnStack(int moreThan, String canonicalName) {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
int count = 0;
for (StackTraceElement element : stackTrace) {
if (element.getClassName().startsWith(canonicalName)) {
count++;
}
}
return count > moreThan;
} | java | {
"resource": ""
} |
q15607 | PhotonCoreValidator.validateHTMLConfiguration | train | public static void validateHTMLConfiguration () throws IllegalStateException
{
// This will throw an IllegalStateException for wrong files in html/js.xml
// and html/css.xml
PhotonCSS.readCSSIncludesForGlobal (new ClassPathResource (PhotonCSS.DEFAULT_FILENAME));
PhotonJS.readJSIncludesForGlobal (new ClassPathResource (PhotonJS.DEFAULT_FILENAME));
} | java | {
"resource": ""
} |
q15608 | FineUploader5Form.setElementID | train | @Nonnull
public FineUploader5Form setElementID (@Nonnull @Nonempty final String sElementID)
{
ValueEnforcer.notEmpty (sElementID, "ElementID");
m_sFormElementID = sElementID;
return this;
} | java | {
"resource": ""
} |
q15609 | AuditHelper.setAuditor | train | public static void setAuditor (@Nonnull final IAuditor aAuditor)
{
ValueEnforcer.notNull (aAuditor, "Auditor");
s_aRWLock.writeLocked ( () -> s_aAuditor = aAuditor);
} | java | {
"resource": ""
} |
q15610 | JarXtractor.startsWith | train | private static boolean startsWith(String str, String... prefixes) {
for (String prefix : prefixes) {
if (str.startsWith(prefix)) return true;
}
return false;
} | java | {
"resource": ""
} |
q15611 | JarXtractor.extractClassNames | train | private static List<String> extractClassNames(String jarName) throws IOException {
List<String> classes = new LinkedList<String>();
ZipInputStream orig = new ZipInputStream(new FileInputStream(jarName));
for (ZipEntry entry = orig.getNextEntry(); entry != null; entry = orig.getNextEntry()) {
String fullName = entry.getName().replaceAll("/", ".").replace(".class", "");
classes.add(fullName);
}
orig.close();
return classes;
} | java | {
"resource": ""
} |
q15612 | JarXtractor.main | train | public static void main(String[] args) throws IOException {
if (args.length != 1) {
System.out.println("There should be an argument: path to a jar.");
System.exit(0);
}
String jarInput = args[0];
extract(new File(jarInput), new File("/tmp/junit-ekstazi-agent.jar"),
new String[] { Names.EKSTAZI_PACKAGE_BIN }, new String[] {});
for (String name : extractClassNames("/tmp/junit-ekstazi-agent.jar")) {
System.out.println(name);
}
} | java | {
"resource": ""
} |
q15613 | HCJSNodeDetector.isJSNode | train | public static boolean isJSNode (@Nullable final IHCNode aNode)
{
final IHCNode aUnwrappedNode = HCHelper.getUnwrappedNode (aNode);
return isDirectJSNode (aUnwrappedNode);
} | java | {
"resource": ""
} |
q15614 | HCJSNodeDetector.isJSInlineNode | train | public static boolean isJSInlineNode (@Nullable final IHCNode aNode)
{
final IHCNode aUnwrappedNode = HCHelper.getUnwrappedNode (aNode);
return isDirectJSInlineNode (aUnwrappedNode);
} | java | {
"resource": ""
} |
q15615 | HCJSNodeDetector.isJSFileNode | train | public static boolean isJSFileNode (@Nullable final IHCNode aNode)
{
final IHCNode aUnwrappedNode = HCHelper.getUnwrappedNode (aNode);
return isDirectJSFileNode (aUnwrappedNode);
} | java | {
"resource": ""
} |
q15616 | JSAnonymousFunction.param | train | @Nonnull
public JSVar param (@Nonnull @Nonempty final String sName)
{
final JSVar aVar = new JSVar (sName, null);
m_aParams.add (aVar);
return aVar;
} | java | {
"resource": ""
} |
q15617 | JSAnonymousFunction.body | train | @Nonnull
public JSBlock body ()
{
if (m_aBody == null)
m_aBody = new JSBlock ().newlineAtEnd (false);
return m_aBody;
} | java | {
"resource": ""
} |
q15618 | HCCol.perc | train | @Nonnull
public static HCCol perc (@Nonnegative final int nPerc)
{
return new HCCol ().setWidth (ECSSUnit.perc (nPerc));
} | java | {
"resource": ""
} |
q15619 | SnomedLookup.enrichXml | train | public int enrichXml(final MMOs root) throws SQLException {
int count = 0;
// TODO: take out the print statements
for (final MMO mmo : root.getMMO()) {
for (final Utterance utterance : mmo.getUtterances().getUtterance()) {
for (final Phrase phrase : utterance.getPhrases().getPhrase()) {
System.out.printf("Phrase: %s\n", phrase.getPhraseText());
for (final Mapping mapping : phrase.getMappings().getMapping()) {
System.out.printf("Score: %s\n", mapping.getMappingScore());
for (final Candidate candidate : mapping.getMappingCandidates().getCandidate()) {
final Collection<String> semTypes = new ArrayList<>();
for (final SemType st : candidate.getSemTypes().getSemType()) {
semTypes.add(st.getvalue());
}
// the actual line of work
count += addSnomedId(candidate) ? 1 : 0;
System.out.printf(" %-5s %-9s %s %s %s %s\n",
candidate.getCandidateScore(),
candidate.getCandidateCUI(),
candidate.getSnomedId(),
candidate.getCandidatePreferred(),
semTypes,
candidate.getSources().getSource());
}
}
System.out.println();
}
}
}
return count;
} | java | {
"resource": ""
} |
q15620 | SnomedLookup.addSnomedId | train | public boolean addSnomedId(final Candidate candidate) throws SQLException {
final SnomedTerm result = findFromCuiAndDesc(candidate.getCandidateCUI(), candidate.getCandidatePreferred());
if (result != null) {
candidate.setSnomedId(result.snomedId);
candidate.setTermType(result.termType);
return true;
}
else {
// TODO: log this somewhere?
System.err.printf("WARNING! Could not find the SNOMED CT concept id for UMLS CUI: %s: '%s'\n",
candidate.getCandidateCUI(), candidate.getCandidatePreferred());
return false;
}
} | java | {
"resource": ""
} |
q15621 | XHTMLParser.looksLikeXHTML | train | public static boolean looksLikeXHTML (@Nullable final String sText)
{
// If the text contains an open angle bracket followed by a character that
// we think of it as HTML
// (?s) enables the "dotall" mode - see Pattern.DOTALL
return StringHelper.hasText (sText) && RegExHelper.stringMatchesPattern ("(?s).*<[a-zA-Z].+", sText);
} | java | {
"resource": ""
} |
q15622 | XHTMLParser.isValidXHTMLFragment | train | public boolean isValidXHTMLFragment (@Nullable final String sXHTMLFragment)
{
return StringHelper.hasNoText (sXHTMLFragment) || parseXHTMLFragment (sXHTMLFragment) != null;
} | java | {
"resource": ""
} |
q15623 | XHTMLParser.unescapeXHTMLFragment | train | @Nullable
public IMicroContainer unescapeXHTMLFragment (@Nullable final String sXHTML)
{
// Ensure that the content is surrounded by a single tag
final IMicroDocument aDoc = parseXHTMLFragment (sXHTML);
if (aDoc != null && aDoc.getDocumentElement () != null)
{
// Find "body" case insensitive
final IMicroElement eBody = aDoc.getDocumentElement ().getFirstChildElement (EHTMLElement.BODY.getElementName ());
if (eBody != null)
{
final IMicroContainer ret = new MicroContainer ();
if (eBody.hasChildren ())
{
// We need a copy because detachFromParent is modifying
for (final IMicroNode aChildNode : eBody.getAllChildren ())
ret.appendChild (aChildNode.detachFromParent ());
}
return ret;
}
}
return null;
} | java | {
"resource": ""
} |
q15624 | AbstractBusinessObjectMicroTypeConverter.readAsLocalDateTime | train | @Nullable
@ContainsSoftMigration
public static LocalDateTime readAsLocalDateTime (@Nonnull final IMicroElement aElement,
@Nonnull final IMicroQName aLDTName,
@Nonnull final String aDTName)
{
LocalDateTime aLDT = aElement.getAttributeValueWithConversion (aLDTName, LocalDateTime.class);
if (aLDT == null)
{
final ZonedDateTime aDT = aElement.getAttributeValueWithConversion (aDTName, ZonedDateTime.class);
if (aDT != null)
aLDT = aDT.toLocalDateTime ();
}
return aLDT;
} | java | {
"resource": ""
} |
q15625 | BootstrapDisplayBuilder.display | train | @Nonnull
public BootstrapDisplayBuilder display (@Nonnull final EBootstrapDisplayType eDisplay)
{
ValueEnforcer.notNull (eDisplay, "eDisplay");
m_eDisplay = eDisplay;
return this;
} | java | {
"resource": ""
} |
q15626 | HCHead.addCSSAt | train | @Nonnull
public final HCHead addCSSAt (@Nonnegative final int nIndex, @Nonnull final IHCNode aCSS)
{
ValueEnforcer.notNull (aCSS, "CSS");
if (!HCCSSNodeDetector.isCSSNode (aCSS))
throw new IllegalArgumentException (aCSS + " is not a valid CSS node!");
m_aCSS.add (nIndex, aCSS);
return this;
} | java | {
"resource": ""
} |
q15627 | HCHead.addJS | train | @Nonnull
public final HCHead addJS (@Nonnull final IHCNode aJS)
{
ValueEnforcer.notNull (aJS, "JS");
if (!HCJSNodeDetector.isJSNode (aJS))
throw new IllegalArgumentException (aJS + " is not a valid JS node!");
m_aJS.add (aJS);
return this;
} | java | {
"resource": ""
} |
q15628 | HCHead.addJSAt | train | @Nonnull
public final HCHead addJSAt (@Nonnegative final int nIndex, @Nonnull final IHCNode aJS)
{
ValueEnforcer.notNull (aJS, "JS");
if (!HCJSNodeDetector.isJSNode (aJS))
throw new IllegalArgumentException (aJS + " is not a valid JS node!");
m_aJS.add (nIndex, aJS);
return this;
} | java | {
"resource": ""
} |
q15629 | Ekstazi.inst | train | public static Ekstazi inst() {
if (inst != null) return inst;
synchronized (Ekstazi.class) {
if (inst == null) {
inst = new Ekstazi();
}
}
return inst;
} | java | {
"resource": ""
} |
q15630 | Ekstazi.endClassCoverage | train | public void endClassCoverage(String className, boolean isFailOrError) {
File testResultsDir = new File(Config.ROOT_DIR_V, Names.TEST_RESULTS_DIR_NAME);
File outcomeFile = new File(testResultsDir, className);
if (isFailOrError) {
// TODO: long names.
testResultsDir.mkdirs();
try {
outcomeFile.createNewFile();
} catch (IOException e) {
Log.e("Unable to create file for a failing test: " + className, e);
}
} else {
outcomeFile.delete();
}
endClassCoverage(className);
} | java | {
"resource": ""
} |
q15631 | Ekstazi.initAndReportSuccess | train | private boolean initAndReportSuccess() {
// Load configuration.
Config.loadConfig();
// Initialize storer, hashes, and analyzer.
mDependencyAnalyzer = Config.createDepenencyAnalyzer();
// Establish if Tool is enabled.
boolean isEnabled = establishIfEnabled();
// Return if not enabled or code should not be instrumented.
if (!isEnabled || !Config.X_INSTRUMENT_CODE_V || isEkstaziSystemClassLoader()) {
return isEnabled;
}
// Set the agent at runtime if not already set.
Instrumentation instrumentation = EkstaziAgent.getInstrumentation();
if (instrumentation == null) {
Log.d("Agent has not been set previously");
instrumentation = DynamicEkstazi.initAgentAtRuntimeAndReportSuccess();
if (instrumentation == null) {
Log.d("No Instrumentation object found; enabling Ekstazi without using any instrumentation");
return true;
}
} else {
Log.d("Agent has been set previously");
}
return true;
} | java | {
"resource": ""
} |
q15632 | Emitter.emitPluginLines | train | protected void emitPluginLines (final MarkdownHCStack aOut, final Line aLines, @Nonnull final String sMeta)
{
Line aLine = aLines;
String sIDPlugin = sMeta;
String sParams = null;
ICommonsMap <String, String> aParams = null;
final int nIdxOfSpace = sMeta.indexOf (' ');
if (nIdxOfSpace != -1)
{
sIDPlugin = sMeta.substring (0, nIdxOfSpace);
sParams = sMeta.substring (nIdxOfSpace + 1);
if (sParams != null)
{
aParams = parsePluginParams (sParams);
}
}
if (aParams == null)
{
aParams = new CommonsHashMap <> ();
}
final ICommonsList <String> aList = new CommonsArrayList <> ();
while (aLine != null)
{
if (aLine.m_bIsEmpty)
aList.add ("");
else
aList.add (aLine.m_sValue);
aLine = aLine.m_aNext;
}
final AbstractMarkdownPlugin aPlugin = m_aPlugins.get (sIDPlugin);
if (aPlugin != null)
{
aPlugin.emit (aOut, aList, aParams);
}
} | java | {
"resource": ""
} |
q15633 | Dates.copy | train | public static Date copy(final Date d) {
if (d == null) {
return null;
} else {
return new Date(d.getTime());
}
} | java | {
"resource": ""
} |
q15634 | Util.list | train | public static <A> List<A> list(A... elements) {
final List<A> list = new ArrayList<A>(elements.length);
for (A element : elements) {
list.add(element);
}
return list;
} | java | {
"resource": ""
} |
q15635 | Util.set | train | public static <A> Set<A> set(A... elements) {
final Set<A> set = new HashSet<A>(elements.length);
for (A element : elements) {
set.add(element);
}
return set;
} | java | {
"resource": ""
} |
q15636 | Util.execute | train | public static <A> A execute(ExceptionAction<A> action) {
try {
return action.doAction();
} catch (RuntimeException e) {
throw e;
} catch (Error e) {
throw e;
} catch (Throwable e) {
throw new RuntimeException(e);
}
} | java | {
"resource": ""
} |
q15637 | FormErrorList.addFieldInfo | train | public void addFieldInfo (@Nonnull @Nonempty final String sFieldName, @Nonnull @Nonempty final String sText)
{
add (SingleError.builderInfo ().setErrorFieldName (sFieldName).setErrorText (sText).build ());
} | java | {
"resource": ""
} |
q15638 | FormErrorList.addFieldWarning | train | public void addFieldWarning (@Nonnull @Nonempty final String sFieldName, @Nonnull @Nonempty final String sText)
{
add (SingleError.builderWarn ().setErrorFieldName (sFieldName).setErrorText (sText).build ());
} | java | {
"resource": ""
} |
q15639 | FormErrorList.addFieldError | train | public void addFieldError (@Nonnull @Nonempty final String sFieldName, @Nonnull @Nonempty final String sText)
{
add (SingleError.builderError ().setErrorFieldName (sFieldName).setErrorText (sText).build ());
} | java | {
"resource": ""
} |
q15640 | UserGroupManager.createNewUserGroup | train | @Nonnull
public IUserGroup createNewUserGroup (@Nonnull @Nonempty final String sName,
@Nullable final String sDescription,
@Nullable final Map <String, String> aCustomAttrs)
{
// Create user group
final UserGroup aUserGroup = new UserGroup (sName, sDescription, aCustomAttrs);
m_aRWLock.writeLocked ( () -> {
// Store
internalCreateItem (aUserGroup);
});
AuditHelper.onAuditCreateSuccess (UserGroup.OT, aUserGroup.getID (), sName, sDescription, aCustomAttrs);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupCreated (aUserGroup, false));
return aUserGroup;
} | java | {
"resource": ""
} |
q15641 | UserGroupManager.createPredefinedUserGroup | train | @Nonnull
public IUserGroup createPredefinedUserGroup (@Nonnull @Nonempty final String sID,
@Nonnull @Nonempty final String sName,
@Nullable final String sDescription,
@Nullable final Map <String, String> aCustomAttrs)
{
// Create user group
final UserGroup aUserGroup = new UserGroup (StubObject.createForCurrentUserAndID (sID, aCustomAttrs),
sName,
sDescription);
m_aRWLock.writeLocked ( () -> {
// Store
internalCreateItem (aUserGroup);
});
AuditHelper.onAuditCreateSuccess (UserGroup.OT,
aUserGroup.getID (),
"predefined-usergroup",
sName,
sDescription,
aCustomAttrs);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupCreated (aUserGroup, true));
return aUserGroup;
} | java | {
"resource": ""
} |
q15642 | UserGroupManager.deleteUserGroup | train | @Nonnull
public EChange deleteUserGroup (@Nullable final String sUserGroupID)
{
if (StringHelper.hasNoText (sUserGroupID))
return EChange.UNCHANGED;
final UserGroup aDeletedUserGroup = getOfID (sUserGroupID);
if (aDeletedUserGroup == null)
{
AuditHelper.onAuditDeleteFailure (UserGroup.OT, "no-such-usergroup-id", sUserGroupID);
return EChange.UNCHANGED;
}
if (aDeletedUserGroup.isDeleted ())
{
AuditHelper.onAuditDeleteFailure (UserGroup.OT, "already-deleted", sUserGroupID);
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
if (BusinessObjectHelper.setDeletionNow (aDeletedUserGroup).isUnchanged ())
{
AuditHelper.onAuditDeleteFailure (UserGroup.OT, "already-deleted", sUserGroupID);
return EChange.UNCHANGED;
}
internalMarkItemDeleted (aDeletedUserGroup);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditDeleteSuccess (UserGroup.OT, sUserGroupID);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupDeleted (aDeletedUserGroup));
return EChange.CHANGED;
} | java | {
"resource": ""
} |
q15643 | UserGroupManager.undeleteUserGroup | train | @Nonnull
public EChange undeleteUserGroup (@Nullable final String sUserGroupID)
{
final UserGroup aUserGroup = getOfID (sUserGroupID);
if (aUserGroup == null)
{
AuditHelper.onAuditUndeleteFailure (UserGroup.OT, sUserGroupID, "no-such-id");
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
if (BusinessObjectHelper.setUndeletionNow (aUserGroup).isUnchanged ())
return EChange.UNCHANGED;
internalMarkItemUndeleted (aUserGroup);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditUndeleteSuccess (UserGroup.OT, sUserGroupID);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupUndeleted (aUserGroup));
return EChange.CHANGED;
} | java | {
"resource": ""
} |
q15644 | UserGroupManager.renameUserGroup | train | @Nonnull
public EChange renameUserGroup (@Nullable final String sUserGroupID, @Nonnull @Nonempty final String sNewName)
{
// Resolve user group
final UserGroup aUserGroup = getOfID (sUserGroupID);
if (aUserGroup == null)
{
AuditHelper.onAuditModifyFailure (UserGroup.OT, sUserGroupID, "no-such-usergroup-id", "name");
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
if (aUserGroup.setName (sNewName).isUnchanged ())
return EChange.UNCHANGED;
BusinessObjectHelper.setLastModificationNow (aUserGroup);
internalUpdateItem (aUserGroup);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditModifySuccess (UserGroup.OT, "name", sUserGroupID, sNewName);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupRenamed (aUserGroup));
return EChange.CHANGED;
} | java | {
"resource": ""
} |
q15645 | UserGroupManager.unassignUserFromAllUserGroups | train | @Nonnull
public EChange unassignUserFromAllUserGroups (@Nullable final String sUserID)
{
if (StringHelper.hasNoText (sUserID))
return EChange.UNCHANGED;
final ICommonsList <IUserGroup> aAffectedUserGroups = new CommonsArrayList <> ();
m_aRWLock.writeLock ().lock ();
try
{
EChange eChange = EChange.UNCHANGED;
for (final UserGroup aUserGroup : internalDirectGetAll ())
if (aUserGroup.unassignUser (sUserID).isChanged ())
{
aAffectedUserGroups.add (aUserGroup);
BusinessObjectHelper.setLastModificationNow (aUserGroup);
internalUpdateItem (aUserGroup);
eChange = EChange.CHANGED;
}
if (eChange.isUnchanged ())
return EChange.UNCHANGED;
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditModifySuccess (UserGroup.OT, "unassign-user-from-all-usergroups", sUserID);
// Execute callback as the very last action
for (final IUserGroup aUserGroup : aAffectedUserGroups)
m_aCallbacks.forEach (aCB -> aCB.onUserGroupUserAssignment (aUserGroup, sUserID, false));
return EChange.CHANGED;
}
/**
* Check if the passed user is assigned to the specified user group
*
* @param sUserGroupID
* ID of the user group to check
* @param sUserID
* ID of the user to be checked.
* @return <code>true</code> if the specified user is assigned to the
* specified user group.
*/
public boolean isUserAssignedToUserGroup (@Nullable final String sUserGroupID, @Nullable final String sUserID)
{
if (StringHelper.hasNoText (sUserID))
return false;
final IUserGroup aUserGroup = getOfID (sUserGroupID);
return aUserGroup == null ? false : aUserGroup.containsUserID (sUserID);
} | java | {
"resource": ""
} |
q15646 | UserGroupManager.getAllUserGroupsWithAssignedUser | train | @Nonnull
@ReturnsMutableCopy
public ICommonsList <IUserGroup> getAllUserGroupsWithAssignedUser (@Nullable final String sUserID)
{
if (StringHelper.hasNoText (sUserID))
return new CommonsArrayList <> ();
return getAll (aUserGroup -> aUserGroup.containsUserID (sUserID));
} | java | {
"resource": ""
} |
q15647 | UserGroupManager.getAllUserGroupIDsWithAssignedUser | train | @Nonnull
@ReturnsMutableCopy
public ICommonsList <String> getAllUserGroupIDsWithAssignedUser (@Nullable final String sUserID)
{
if (StringHelper.hasNoText (sUserID))
return new CommonsArrayList <> ();
return getAllMapped (aUserGroup -> aUserGroup.containsUserID (sUserID), aUserGroup -> aUserGroup.getID ());
} | java | {
"resource": ""
} |
q15648 | UserGroupManager.unassignRoleFromAllUserGroups | train | @Nonnull
public EChange unassignRoleFromAllUserGroups (@Nullable final String sRoleID)
{
if (StringHelper.hasNoText (sRoleID))
return EChange.UNCHANGED;
final ICommonsList <IUserGroup> aAffectedUserGroups = new CommonsArrayList <> ();
m_aRWLock.writeLock ().lock ();
try
{
EChange eChange = EChange.UNCHANGED;
for (final UserGroup aUserGroup : internalDirectGetAll ())
if (aUserGroup.unassignRole (sRoleID).isChanged ())
{
aAffectedUserGroups.add (aUserGroup);
BusinessObjectHelper.setLastModificationNow (aUserGroup);
internalUpdateItem (aUserGroup);
eChange = EChange.CHANGED;
}
if (eChange.isUnchanged ())
return EChange.UNCHANGED;
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditModifySuccess (UserGroup.OT, "unassign-role-from-all-usergroups", sRoleID);
// Execute callback as the very last action
for (final IUserGroup aUserGroup : aAffectedUserGroups)
m_aCallbacks.forEach (aCB -> aCB.onUserGroupRoleAssignment (aUserGroup, sRoleID, false));
return EChange.CHANGED;
}
/**
* Get a collection of all user groups to which a certain role is assigned to.
*
* @param sRoleID
* The role ID to search
* @return A non-<code>null</code>but may be empty collection with all
* matching user groups.
*/
@Nonnull
@ReturnsMutableCopy
public ICommonsList <IUserGroup> getAllUserGroupsWithAssignedRole (@Nullable final String sRoleID)
{
if (StringHelper.hasNoText (sRoleID))
return getNone ();
return getAll (aUserGroup -> aUserGroup.containsRoleID (sRoleID));
} | java | {
"resource": ""
} |
q15649 | UserGroupManager.getAllUserGroupIDsWithAssignedRole | train | @Nonnull
@ReturnsMutableCopy
public ICommonsList <String> getAllUserGroupIDsWithAssignedRole (@Nullable final String sRoleID)
{
if (StringHelper.hasNoText (sRoleID))
return getNone ();
return getAllMapped (aUserGroup -> aUserGroup.containsRoleID (sRoleID), IUserGroup::getID);
} | java | {
"resource": ""
} |
q15650 | AbstractHCNode.internalSetNodeState | train | public final void internalSetNodeState (@Nonnull final EHCNodeState eNodeState)
{
if (DEBUG_NODE_STATE)
{
ValueEnforcer.notNull (eNodeState, "NodeState");
if (m_eNodeState.isAfter (eNodeState))
HCConsistencyChecker.consistencyError ("The new node state is invalid. Got " +
eNodeState +
" but having " +
m_eNodeState);
}
m_eNodeState = eNodeState;
} | java | {
"resource": ""
} |
q15651 | ClassesCache.check | train | public static boolean check(Class<?> clz) {
if (Config.CACHE_SEEN_CLASSES_V) {
int index = hash(clz);
if (CACHE[index] == clz) {
return true;
}
CACHE[index] = clz;
}
return false;
} | java | {
"resource": ""
} |
q15652 | StringSinkFactory.getResults | train | public Map<String, String> getResults() {
final Map<String, String> results = new HashMap<String, String>(sinks.size());
for (Map.Entry<String, StringSink> entry : sinks.entrySet()) {
results.put(entry.getKey(), entry.getValue().result());
}
return Collections.unmodifiableMap(results);
} | java | {
"resource": ""
} |
q15653 | AffectedChecker.main | train | public static void main(String[] args) {
// Parse arguments.
String coverageDirName = null;
if (args.length == 0) {
System.out.println("Incorrect arguments. Directory with coverage has to be specified.");
System.exit(1);
}
coverageDirName = args[0];
String mode = null;
if (args.length > 1) {
mode = args[1];
}
boolean forceCacheUse = false;
if (args.length > 2) {
forceCacheUse = args[2].equals(FORCE_CACHE_USE);
}
Set<String> allClasses = new HashSet<String>();
Set<String> affectedClasses = new HashSet<String>();
if (args.length > 3) {
String options = args[3];
Config.loadConfig(options, true);
} else {
Config.loadConfig();
}
List<String> nonAffectedClasses = findNonAffectedClasses(coverageDirName, forceCacheUse, allClasses, affectedClasses);
// Print non affected classes.
printNonAffectedClasses(allClasses, affectedClasses, nonAffectedClasses, mode);
} | java | {
"resource": ""
} |
q15654 | AffectedChecker.findNonAffectedClasses | train | private static List<String> findNonAffectedClasses(String workingDirectory) {
Set<String> allClasses = new HashSet<String>();
Set<String> affectedClasses = new HashSet<String>();
loadConfig(workingDirectory);
// Find non affected classes.
List<String> nonAffectedClasses = findNonAffectedClasses(Config.ROOT_DIR_V, true, allClasses,
affectedClasses);
// Format list to include class names in expected format for Ant and Maven.
return formatNonAffectedClassesForAntAndMaven(nonAffectedClasses);
} | java | {
"resource": ""
} |
q15655 | AffectedChecker.printNonAffectedClasses | train | private static void printNonAffectedClasses(Set<String> allClasses, Set<String> affectedClasses,
List<String> nonAffectedClasses, String mode) {
if (mode != null && mode.equals(ANT_MODE)) {
StringBuilder sb = new StringBuilder();
for (String className : nonAffectedClasses) {
className = className.replaceAll("\\.", "/");
sb.append("<exclude name=\"" + className + ".java\"/>");
}
System.out.println(sb);
} else if (mode != null && mode.equals(MAVEN_SIMPLE_MODE)) {
StringBuilder sb = new StringBuilder();
for (String className : nonAffectedClasses) {
className = className.replaceAll("\\.", "/");
sb.append("<exclude>");
sb.append(className).append(".java");
sb.append("</exclude>");
}
System.out.println(sb);
} else if (mode != null && mode.equals(MAVEN_MODE)) {
StringBuilder sb = new StringBuilder();
sb.append("<excludes>");
for (String className : nonAffectedClasses) {
className = className.replaceAll("\\.", "/");
sb.append("<exclude>");
sb.append(className).append(".java");
sb.append("</exclude>");
}
sb.append("</excludes>");
System.out.println(sb);
} else if (mode != null && mode.equals(DEBUG_MODE)) {
System.out.println("AFFECTED: " + affectedClasses);
System.out.println("NONAFFECTED: " + nonAffectedClasses);
} else {
for (String className : nonAffectedClasses) {
System.out.println(className);
}
}
} | java | {
"resource": ""
} |
q15656 | AffectedChecker.includeAffected | train | private static void includeAffected(Set<String> allClasses, Set<String> affectedClasses, List<File> sortedFiles) {
Storer storer = Config.createStorer();
Hasher hasher = Config.createHasher();
NameBasedCheck classCheck = Config.DEBUG_MODE_V != Config.DebugMode.NONE ?
new DebugNameCheck(storer, hasher, DependencyAnalyzer.CLASS_EXT) :
new NameBasedCheck(storer, hasher, DependencyAnalyzer.CLASS_EXT);
NameBasedCheck covCheck = new NameBasedCheck(storer, hasher, DependencyAnalyzer.COV_EXT);
MethodCheck methodCheck = new MethodCheck(storer, hasher);
String prevClassName = null;
for (File file : sortedFiles) {
String fileName = file.getName();
String dirName = file.getParent();
String className = null;
if (file.isDirectory()) {
continue;
}
if (fileName.endsWith(DependencyAnalyzer.COV_EXT)) {
className = covCheck.includeAll(fileName, dirName);
} else if (fileName.endsWith(DependencyAnalyzer.CLASS_EXT)) {
className = classCheck.includeAll(fileName, dirName);
} else {
className = methodCheck.includeAll(fileName, dirName);
}
// Reset after some time to free space.
if (prevClassName != null && className != null && !prevClassName.equals(className)) {
methodCheck.includeAffected(affectedClasses);
methodCheck = new MethodCheck(Config.createStorer(), Config.createHasher());
}
if (className != null) {
allClasses.add(className);
prevClassName = className;
}
}
classCheck.includeAffected(affectedClasses);
covCheck.includeAffected(affectedClasses);
methodCheck.includeAffected(affectedClasses);
} | java | {
"resource": ""
} |
q15657 | DataTablesDom.addCustom | train | @Nonnull
public DataTablesDom addCustom (@Nonnull @Nonempty final String sStr)
{
ValueEnforcer.notEmpty (sStr, "Str");
_internalAdd (sStr);
return this;
} | java | {
"resource": ""
} |
q15658 | FineUploader5Validation.setItemLimit | train | @Nonnull
public FineUploader5Validation setItemLimit (@Nonnegative final int nItemLimit)
{
ValueEnforcer.isGE0 (nItemLimit, "ItemLimit");
m_nValidationItemLimit = nItemLimit;
return this;
} | java | {
"resource": ""
} |
q15659 | FineUploader5Validation.setMinSizeLimit | train | @Nonnull
public FineUploader5Validation setMinSizeLimit (@Nonnegative final int nMinSizeLimit)
{
ValueEnforcer.isGE0 (nMinSizeLimit, "MinSizeLimit");
m_nValidationMinSizeLimit = nMinSizeLimit;
return this;
} | java | {
"resource": ""
} |
q15660 | FineUploader5Validation.setSizeLimit | train | @Nonnull
public FineUploader5Validation setSizeLimit (@Nonnegative final int nSizeLimit)
{
ValueEnforcer.isGE0 (nSizeLimit, "SizeLimit");
m_nValidationSizeLimit = nSizeLimit;
return this;
} | java | {
"resource": ""
} |
q15661 | AnalyseHandler.sendTextToServer | train | private void sendTextToServer() {
statusLabel.setText("");
conceptList.clear();
// don't do anything if we have no text
final String text = mainTextArea.getText();
if (text.length() < 1) {
statusLabel.setText(messages.pleaseEnterTextLabel());
return;
}
// disable interaction while we wait for the response
glassPanel.setPositionAndShow();
// build up the AnalysisRequest JSON object
// start with any options
final JSONArray options = new JSONArray();
setSemanticTypesOption(types, options);
// defaults
options.set(options.size(), new JSONString("word_sense_disambiguation"));
options.set(options.size(), new JSONString("composite_phrases 8"));
options.set(options.size(), new JSONString("no_derivational_variants"));
options.set(options.size(), new JSONString("strict_model"));
options.set(options.size(), new JSONString("ignore_word_order"));
options.set(options.size(), new JSONString("allow_large_n"));
options.set(options.size(), new JSONString("restrict_to_sources SNOMEDCT_US"));
final JSONObject analysisRequest = new JSONObject();
analysisRequest.put("text", new JSONString(text));
analysisRequest.put("options", options);
// send the input to the server
final RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, webserviceUrl);
builder.setHeader("Content-Type", MediaType.APPLICATION_JSON);
builder.setRequestData(analysisRequest.toString());
// create the async callback
builder.setCallback(new SnomedRequestCallback(conceptList, statusLabel, glassPanel, typeCodeToDescription));
// send the request
try { builder.send(); }
catch (final RequestException e) {
statusLabel.setText(messages.problemPerformingAnalysisLabel());
GWT.log("There was a problem performing the analysis: " + e.getMessage(), e);
glassPanel.hide();
}
} | java | {
"resource": ""
} |
q15662 | DummyParser.parse | train | @Override
public ParseResult parse(Source source) {
if (!testSrcInfo.equals(source.getSrcInfo())) {
throw new RuntimeException("testSrcInfo and source.getSrcInfo were not equal. testSrcInfo = " + testSrcInfo + ", source.getSrcInfo = " + source.getSrcInfo());
}
try {
BufferedReader reader = source.createReader();
try {
if (!testString.equals(reader.readLine())) {
throw new RuntimeException("testString and reader.readLine() were not equal");
}
final String secondLine = reader.readLine();
if (secondLine != null) {
throw new RuntimeException("got a second line '" + secondLine + "' from the reader");
}
} finally {
reader.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return testResult;
} | java | {
"resource": ""
} |
q15663 | PasswordHashCreatorManager.registerPasswordHashCreator | train | public void registerPasswordHashCreator (@Nonnull final IPasswordHashCreator aPasswordHashCreator)
{
ValueEnforcer.notNull (aPasswordHashCreator, "PasswordHashCreator");
final String sAlgorithmName = aPasswordHashCreator.getAlgorithmName ();
if (StringHelper.hasNoText (sAlgorithmName))
throw new IllegalArgumentException ("PasswordHashCreator algorithm '" + aPasswordHashCreator + "' is empty!");
m_aRWLock.writeLocked ( () -> {
if (m_aPasswordHashCreators.containsKey (sAlgorithmName))
throw new IllegalArgumentException ("Another PasswordHashCreator for algorithm '" +
sAlgorithmName +
"' is already registered!");
m_aPasswordHashCreators.put (sAlgorithmName, aPasswordHashCreator);
});
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Registered password hash creator algorithm '" + sAlgorithmName + "' to " + aPasswordHashCreator);
} | java | {
"resource": ""
} |
q15664 | PasswordHashCreatorManager.getPasswordHashCreatorOfAlgorithm | train | @Nullable
public IPasswordHashCreator getPasswordHashCreatorOfAlgorithm (@Nullable final String sAlgorithmName)
{
return m_aRWLock.readLocked ( () -> m_aPasswordHashCreators.get (sAlgorithmName));
} | java | {
"resource": ""
} |
q15665 | StandardChecker.check | train | private List<SemanticError> check(DataType dataType) {
logger.finer("Checking semantic constraints on datatype " + dataType.name);
final List<SemanticError> errors = new ArrayList<SemanticError>();
final Set<String> constructorNames = new HashSet<String>();
for(Constructor constructor : dataType.constructors) {
logger.finest("Checking semantic constraints on constructor " + constructor.name + " in datatype " + dataType.name);
if (dataType.constructors.size() > 1 && dataType.name.equals(constructor.name)) {
logger.info("Constructor with same name as its data type " + dataType.name + ".");
errors.add(_ConstructorDataTypeConflict(dataType.name));
}
if (constructorNames.contains(constructor.name)) {
logger.info("Two constructors with same name " + constructor.name + " in data type " + dataType.name + ".");
errors.add(_DuplicateConstructor(dataType.name, constructor.name));
} else {
constructorNames.add(constructor.name);
}
errors.addAll(check(dataType, constructor));
}
return errors;
} | java | {
"resource": ""
} |
q15666 | StandardChecker.check | train | private List<SemanticError> check(DataType dataType, Constructor constructor) {
logger.finer("Checking semantic constraints on data type " + dataType.name + ", constructor " + constructor.name);
final List<SemanticError> errors = new ArrayList<SemanticError>();
final Set<String> argNames = new HashSet<String>();
for (Arg arg : constructor.args) {
if (argNames.contains(arg.name)) {
errors.add(_DuplicateArgName(dataType.name, constructor.name, arg.name));
} else {
argNames.add(arg.name);
}
errors.addAll(check(dataType, constructor, arg));
}
return errors;
} | java | {
"resource": ""
} |
q15667 | StandardChecker.check | train | private List<SemanticError> check(DataType dataType, Constructor constructor, Arg arg) {
logger.finest("Checking semantic constraints on data type " + dataType.name + ", constructor " + constructor.name);
final List<SemanticError> errors = new ArrayList<SemanticError>();
final Set<ArgModifier> modifiers = new HashSet<ArgModifier>();
for (ArgModifier modifier : arg.modifiers) {
if (modifiers.contains(modifier)) {
final String modName = ASTPrinter.print(modifier);
errors.add(_DuplicateModifier(dataType.name, constructor.name, arg.name, modName));
} else {
modifiers.add(modifier);
}
}
return errors;
} | java | {
"resource": ""
} |
q15668 | ExporterCSV.createCSVWriter | train | @SuppressWarnings ("resource")
@Nonnull
@OverrideOnDemand
@WillCloseWhenClosed
protected CSVWriter createCSVWriter (@Nonnull final OutputStream aOS)
{
return new CSVWriter (new OutputStreamWriter (aOS, m_aCharset)).setSeparatorChar (m_cSeparatorChar)
.setQuoteChar (m_cQuoteChar)
.setEscapeChar (m_cEscapeChar)
.setLineEnd (m_sLineEnd)
.setAvoidFinalLineEnd (m_bAvoidFinalLineEnd);
} | java | {
"resource": ""
} |
q15669 | StaticSelectEkstaziMojo.addJavaAgent | train | private void addJavaAgent(Config.AgentMode junitMode) throws MojoExecutionException {
try {
URL agentJarURL = Types.extractJarURL(EkstaziAgent.class);
if (agentJarURL == null) {
throw new MojoExecutionException("Unable to locate Ekstazi agent");
}
Properties properties = project.getProperties();
String oldValue = properties.getProperty(ARG_LINE_PARAM_NAME);
properties.setProperty(ARG_LINE_PARAM_NAME, prepareEkstaziOptions(agentJarURL, junitMode) + " " + (oldValue == null ? "" : oldValue));
} catch (IOException ex) {
throw new MojoExecutionException("Unable to set path to agent", ex);
} catch (URISyntaxException ex) {
throw new MojoExecutionException("Unable to set path to agent", ex);
}
} | java | {
"resource": ""
} |
q15670 | StaticSelectEkstaziMojo.appendExcludesListToExcludesFile | train | private void appendExcludesListToExcludesFile(Plugin plugin, List<String> nonAffectedClasses) throws MojoExecutionException {
String excludesFileName = extractParamValue(plugin, EXCLUDES_FILE_PARAM_NAME);
File excludesFileFile = new File(excludesFileName);
// First restore file in case it has been modified by this
// plugin before (if 'restore' was not run, or VM crashed).
restoreExcludesFile(plugin);
PrintWriter pw = null;
try {
// Have to restore original file (on shutdown); see
// RestoreMojo.
pw = new PrintWriter(new FileOutputStream(excludesFileFile, true), true);
pw.println(EKSTAZI_LINE_MARKER);
for (String exclude : nonAffectedClasses) {
pw.println(exclude);
}
// If "exclude(s)" is not present, we also have to add default value to exclude inner classes.
if (!isAtLeastOneExcludePresent(plugin)) {
pw.println("**/*$*");
}
} catch (IOException ex) {
throw new MojoExecutionException("Could not access excludesFile", ex);
} finally {
if (pw != null) {
pw.close();
}
}
} | java | {
"resource": ""
} |
q15671 | StaticSelectEkstaziMojo.isParallelOn | train | private boolean isParallelOn(Plugin plugin) throws MojoExecutionException {
String value = extractParamValue(plugin, PARALLEL_PARAM_NAME);
// If value is set and it is not an empty string.
return value != null && !value.equals("");
} | java | {
"resource": ""
} |
q15672 | StaticSelectEkstaziMojo.isForkMode | train | private boolean isForkMode(Plugin plugin) throws MojoExecutionException {
String reuseForksValue = extractParamValue(plugin, REUSE_FORKS_PARAM_NAME);
return reuseForksValue != null && reuseForksValue.equals("false");
} | java | {
"resource": ""
} |
q15673 | StaticSelectEkstaziMojo.isForkDisabled | train | private boolean isForkDisabled(Plugin plugin) throws MojoExecutionException {
String forkCountValue = extractParamValue(plugin, FORK_COUNT_PARAM_NAME);
String forkModeValue = extractParamValue(plugin, FORK_MODE_PARAM_NAME);
return (forkCountValue != null && forkCountValue.equals("0")) ||
(forkModeValue != null && forkModeValue.equals("never"));
} | java | {
"resource": ""
} |
q15674 | StaticSelectEkstaziMojo.checkParameters | train | private void checkParameters(Plugin plugin) throws MojoExecutionException {
// Fail if 'parallel' parameter is used.
if (isParallelOn(plugin)) {
throw new MojoExecutionException("Ekstazi currently does not support parallel parameter");
}
// Fail if fork is disabled.
if (isForkDisabled(plugin)) {
throw new MojoExecutionException("forkCount has to be at least 1");
}
} | java | {
"resource": ""
} |
q15675 | HCRenderer.getPreparedNode | train | @Nonnull
public static <T extends IHCNode> T getPreparedNode (@Nonnull final T aNode,
@Nonnull final IHCHasChildrenMutable <?, ? super IHCNode> aTargetNode,
@Nonnull final IHCConversionSettingsToNode aConversionSettings)
{
// Run the global customizer
aNode.customizeNode (aConversionSettings.getCustomizer (), aConversionSettings.getHTMLVersion (), aTargetNode);
// finalize the node
aNode.finalizeNodeState (aConversionSettings, aTargetNode);
// Consistency check
aNode.consistencyCheck (aConversionSettings);
// No forced registration here
final boolean bForcedResourceRegistration = false;
aNode.registerExternalResources (aConversionSettings, bForcedResourceRegistration);
return aNode;
} | java | {
"resource": ""
} |
q15676 | HCRenderer.prepareForConversion | train | public static void prepareForConversion (@Nonnull final IHCNode aStartNode,
@Nonnull final IHCHasChildrenMutable <?, ? super IHCNode> aGlobalTargetNode,
@Nonnull final IHCConversionSettingsToNode aConversionSettings)
{
ValueEnforcer.notNull (aStartNode, "NodeToBeCustomized");
ValueEnforcer.notNull (aGlobalTargetNode, "TargetNode");
ValueEnforcer.notNull (aConversionSettings, "ConversionSettings");
final IHCCustomizer aCustomizer = aConversionSettings.getCustomizer ();
final EHTMLVersion eHTMLVersion = aConversionSettings.getHTMLVersion ();
// Customize all elements before extracting out-of-band nodes, in case the
// customizer adds some out-of-band nodes as well
// Than finalize and register external resources
final IHCIteratorNonBreakableCallback aCB = (aParentNode, aChildNode) -> {
// If the parent node is suitable, use it, else use the global target
// node
IHCHasChildrenMutable <?, ? super IHCNode> aRealTargetNode;
if (aParentNode instanceof IHCHasChildrenMutable <?, ?>)
{
// Unchecked conversion
aRealTargetNode = GenericReflection.uncheckedCast (aParentNode);
}
else
aRealTargetNode = aGlobalTargetNode;
final int nTargetNodeChildren = aRealTargetNode.getChildCount ();
// Run the global customizer
aChildNode.customizeNode (aCustomizer, eHTMLVersion, aRealTargetNode);
// finalize the node
aChildNode.finalizeNodeState (aConversionSettings, aRealTargetNode);
// Consistency check
aChildNode.consistencyCheck (aConversionSettings);
// No forced registration here
final boolean bForcedResourceRegistration = false;
aChildNode.registerExternalResources (aConversionSettings, bForcedResourceRegistration);
// Something was added?
if (aRealTargetNode.getChildCount () > nTargetNodeChildren)
{
// Recursive call on the target node only.
// It's important to scan the whole tree, as a hierarchy of nodes may
// have been added!
prepareForConversion (aRealTargetNode, aRealTargetNode, aConversionSettings);
}
};
HCHelper.iterateTreeNonBreakable (aStartNode, aCB);
} | java | {
"resource": ""
} |
q15677 | HCRenderer.getAsNode | train | @Nullable
public static IMicroNode getAsNode (@Nonnull final IHCNode aHCNode)
{
return getAsNode (aHCNode, HCSettings.getConversionSettings ());
} | java | {
"resource": ""
} |
q15678 | HCRenderer.getAsNode | train | @SuppressWarnings ("unchecked")
@Nullable
public static IMicroNode getAsNode (@Nonnull final IHCNode aSrcNode,
@Nonnull final IHCConversionSettingsToNode aConversionSettings)
{
IHCNode aConvertNode = aSrcNode;
// Special case for HCHtml - must have been done separately because the
// extraction of the OOB nodes must happen before the HTML HEAD is filled
if (!(aSrcNode instanceof HCHtml))
{
// Determine the target node to use
final boolean bSrcNodeCanHaveChildren = aSrcNode instanceof IHCHasChildrenMutable <?, ?>;
IHCHasChildrenMutable <?, IHCNode> aTempNode;
if (bSrcNodeCanHaveChildren)
{
// Passed node can handle it
aTempNode = (IHCHasChildrenMutable <?, IHCNode>) aSrcNode;
}
else
{
aTempNode = new HCNodeList ();
aTempNode.addChild (aSrcNode);
}
// customize, finalize and extract resources
prepareForConversion (aTempNode, aTempNode, aConversionSettings);
// NOTE: no OOB extraction here, because it is unclear what would happen
// to the nodes.
// Select node to convert to MicroDOM - if something was extracted, use
// the temp node
if (!bSrcNodeCanHaveChildren && aTempNode.getChildCount () > 1)
aConvertNode = aTempNode;
}
final IMicroNode aMicroNode = aConvertNode.convertToMicroNode (aConversionSettings);
return aMicroNode;
} | java | {
"resource": ""
} |
q15679 | HCRenderer.getAsHTMLString | train | @Nonnull
public static String getAsHTMLString (@Nonnull final IHCNode aHCNode)
{
return getAsHTMLString (aHCNode, HCSettings.getConversionSettings ());
} | java | {
"resource": ""
} |
q15680 | HCRenderer.getAsHTMLString | train | @Nonnull
public static String getAsHTMLString (@Nonnull final IHCNode aHCNode,
@Nonnull final IHCConversionSettings aConversionSettings)
{
final IMicroNode aMicroNode = getAsNode (aHCNode, aConversionSettings);
if (aMicroNode == null)
return "";
return MicroWriter.getNodeAsString (aMicroNode, aConversionSettings.getXMLWriterSettings ());
} | java | {
"resource": ""
} |
q15681 | MarkdownHelper.readRawUntil | train | public static int readRawUntil (final StringBuilder out, final String in, final int start, final char end)
{
int pos = start;
while (pos < in.length ())
{
final char ch = in.charAt (pos);
if (ch == end)
break;
out.append (ch);
pos++;
}
return (pos == in.length ()) ? -1 : pos;
} | java | {
"resource": ""
} |
q15682 | LoggedInUserManager.loginUser | train | @Nonnull
public ELoginResult loginUser (@Nullable final String sLoginName, @Nullable final String sPlainTextPassword)
{
return loginUser (sLoginName, sPlainTextPassword, (Iterable <String>) null);
} | java | {
"resource": ""
} |
q15683 | LoggedInUserManager.logoutUser | train | @Nonnull
public EChange logoutUser (@Nullable final String sUserID)
{
LoginInfo aInfo;
m_aRWLock.writeLock ().lock ();
try
{
aInfo = m_aLoggedInUsers.remove (sUserID);
if (aInfo == null)
{
AuditHelper.onAuditExecuteSuccess ("logout", sUserID, "user-not-logged-in");
return EChange.UNCHANGED;
}
// Ensure that the SessionUser is empty. This is only relevant if user is
// manually logged out without destructing the underlying session
final InternalSessionUserHolder aSUH = InternalSessionUserHolder._getInstanceIfInstantiatedInScope (aInfo.getSessionScope ());
if (aSUH != null)
aSUH._reset ();
// Set logout time - in case somebody has a strong reference to the
// LoginInfo object
aInfo.setLogoutDTNow ();
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
if (LOGGER.isInfoEnabled ())
LOGGER.info ("Logged out " +
_getUserIDLogText (sUserID) +
" after " +
Duration.between (aInfo.getLoginDT (), aInfo.getLogoutDT ()).toString ());
AuditHelper.onAuditExecuteSuccess ("logout", sUserID);
// Execute callback as the very last action
m_aUserLogoutCallbacks.forEach (aCB -> aCB.onUserLogout (aInfo));
return EChange.CHANGED;
} | java | {
"resource": ""
} |
q15684 | LoggedInUserManager.getLoginInfo | train | @Nullable
public LoginInfo getLoginInfo (@Nullable final String sUserID)
{
return m_aRWLock.readLocked ( () -> m_aLoggedInUsers.get (sUserID));
} | java | {
"resource": ""
} |
q15685 | Config.loadConfig | train | public static void loadConfig(String options, boolean force) {
if (sIsInitialized && !force) return;
sIsInitialized = true;
Properties commandProperties = unpackOptions(options);
String userHome = getUserHome();
File userHomeDir = new File(userHome, Names.EKSTAZI_CONFIG_FILE);
Properties homeProperties = getProperties(userHomeDir);
File userDir = new File(System.getProperty("user.dir"), Names.EKSTAZI_CONFIG_FILE);
Properties userProperties = getProperties(userDir);
loadProperties(homeProperties);
loadProperties(userProperties);
loadProperties(commandProperties);
// Init Log before any print of config/debug.
Log.init(DEBUG_MODE_V == DebugMode.SCREEN || DEBUG_MODE_V == DebugMode.EVERYWHERE,
DEBUG_MODE_V == DebugMode.FILE || DEBUG_MODE_V == DebugMode.EVERYWHERE,
createFileNameInCoverageDir("debug.log"));
// Print configuration.
printVerbose(userHomeDir, userDir);
} | java | {
"resource": ""
} |
q15686 | Config.checkNamesOfProperties | train | protected static boolean checkNamesOfProperties(Properties props) {
Set<String> names = getAllOptionNames(Config.class);
for (Object key : props.keySet()) {
if (!(key instanceof String) || !names.contains(key)) {
return false;
}
}
return true;
} | java | {
"resource": ""
} |
q15687 | Config.getNumOfNonExperimentalOptions | train | protected static int getNumOfNonExperimentalOptions(Class<?> clz) {
Field[] options = getAllOptions(clz);
int count = 0;
for (Field option : options) {
count += option.getName().startsWith("X_") ? 0 : 1;
}
return count;
} | java | {
"resource": ""
} |
q15688 | Config.main | train | public static void main(String[] args) {
DEBUG_MODE_V = DebugMode.SCREEN;
Log.initScreen();
printVerbose(null, null);
} | java | {
"resource": ""
} |
q15689 | AbstractHCIFrame.setWidth | train | @Nonnull
public final IMPLTYPE setWidth (final int nWidth)
{
if (nWidth >= 0)
m_sWidth = Integer.toString (nWidth);
return thisAsT ();
} | java | {
"resource": ""
} |
q15690 | HCConversionSettings.setCSSWriterSettings | train | @Nonnull
public HCConversionSettings setCSSWriterSettings (@Nonnull final ICSSWriterSettings aCSSWriterSettings)
{
ValueEnforcer.notNull (aCSSWriterSettings, "CSSWriterSettings");
m_aCSSWriterSettings = new CSSWriterSettings (aCSSWriterSettings);
return this;
} | java | {
"resource": ""
} |
q15691 | HCConversionSettings.setJSWriterSettings | train | @Nonnull
public HCConversionSettings setJSWriterSettings (@Nonnull final IJSWriterSettings aJSWriterSettings)
{
ValueEnforcer.notNull (aJSWriterSettings, "JSWriterSettings");
m_aJSWriterSettings = new JSWriterSettings (aJSWriterSettings);
return this;
} | java | {
"resource": ""
} |
q15692 | ReCaptchaServerSideValidator.check | train | @Nonnull
public static ESuccess check (@Nonnull @Nonempty final String sServerSideKey,
@Nullable final String sReCaptchaResponse)
{
ValueEnforcer.notEmpty (sServerSideKey, "ServerSideKey");
if (StringHelper.hasNoText (sReCaptchaResponse))
return ESuccess.SUCCESS;
final HttpClientFactory aHCFactory = new HttpClientFactory ();
// For proxy etc
aHCFactory.setUseSystemProperties (true);
try (HttpClientManager aMgr = new HttpClientManager (aHCFactory))
{
final HttpPost aPost = new HttpPost (new SimpleURL ("https://www.google.com/recaptcha/api/siteverify").add ("secret",
sServerSideKey)
.add ("response",
sReCaptchaResponse)
.getAsURI ());
final ResponseHandlerJson aRH = new ResponseHandlerJson ();
final IJson aJson = aMgr.execute (aPost, aRH);
if (aJson != null && aJson.isObject ())
{
final boolean bSuccess = aJson.getAsObject ().getAsBoolean ("success", false);
if (GlobalDebug.isDebugMode ())
LOGGER.info ("ReCpatcha Response for '" + sReCaptchaResponse + "': " + aJson.getAsJsonString ());
return ESuccess.valueOf (bSuccess);
}
}
catch (final IOException ex)
{
LOGGER.warn ("Error checking ReCaptcha response", ex);
}
return ESuccess.FAILURE;
} | java | {
"resource": ""
} |
q15693 | APIPath.getInvocationURL | train | @Nonnull
public SimpleURL getInvocationURL (@Nonnull final String sBasePath)
{
ValueEnforcer.notNull (sBasePath, "BasePath");
return new SimpleURL (sBasePath + m_sPath);
} | java | {
"resource": ""
} |
q15694 | AbstractHCCheckBox.getHiddenFieldName | train | @Nullable
public final String getHiddenFieldName ()
{
final String sFieldName = getName ();
if (StringHelper.hasNoText (sFieldName))
return null;
return HIDDEN_FIELD_PREFIX + sFieldName;
} | java | {
"resource": ""
} |
q15695 | JSEventMap.addHandler | train | public void addHandler (@Nonnull final EJSEvent eJSEvent, @Nonnull final IHasJSCode aNewHandler)
{
ValueEnforcer.notNull (eJSEvent, "JSEvent");
ValueEnforcer.notNull (aNewHandler, "NewHandler");
CollectingJSCodeProvider aCode = m_aEvents.get (eJSEvent);
if (aCode == null)
{
aCode = new CollectingJSCodeProvider ();
m_aEvents.put (eJSEvent, aCode);
}
aCode.appendFlattened (aNewHandler);
} | java | {
"resource": ""
} |
q15696 | JSEventMap.prependHandler | train | public void prependHandler (@Nonnull final EJSEvent eJSEvent, @Nonnull final IHasJSCode aNewHandler)
{
ValueEnforcer.notNull (eJSEvent, "JSEvent");
ValueEnforcer.notNull (aNewHandler, "NewHandler");
CollectingJSCodeProvider aCode = m_aEvents.get (eJSEvent);
if (aCode == null)
{
aCode = new CollectingJSCodeProvider ();
m_aEvents.put (eJSEvent, aCode);
}
aCode.prepend (aNewHandler);
} | java | {
"resource": ""
} |
q15697 | JSEventMap.setHandler | train | public void setHandler (@Nonnull final EJSEvent eJSEvent, @Nonnull final IHasJSCode aNewHandler)
{
ValueEnforcer.notNull (eJSEvent, "JSEvent");
ValueEnforcer.notNull (aNewHandler, "NewHandler");
// Set only the new handler and remove any existing handler
m_aEvents.put (eJSEvent, new CollectingJSCodeProvider ().appendFlattened (aNewHandler));
} | java | {
"resource": ""
} |
q15698 | FileSourceFactory.createSources | train | @Override
public List<FileSource> createSources(String srcName) {
final File dirOrFile = new File(srcName);
final File[] files = dirOrFile.listFiles(FILTER);
if (files != null) {
final List<FileSource> sources = new ArrayList<FileSource>(files.length);
for (File file : files) {
sources.add(new FileSource(file));
}
return sources;
} else {
return Util.list(new FileSource(dirOrFile));
}
} | java | {
"resource": ""
} |
q15699 | AccessToken.createAccessTokenValidFromNow | train | @Nonnull
public static AccessToken createAccessTokenValidFromNow (@Nullable final String sTokenString)
{
// Length 66 so that the Base64 encoding does not add the "==" signs
// Length must be dividable by 3
final String sRealTokenString = StringHelper.hasText (sTokenString) ? sTokenString : createNewTokenString (66);
return new AccessToken (sRealTokenString, PDTFactory.getCurrentLocalDateTime (), null, new RevocationStatus ());
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.