_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q1600
ComplexDouble.divi
train
public ComplexDouble divi(ComplexDouble c, ComplexDouble result) { double d = c.r * c.r + c.i * c.i; double newR = (r * c.r + i * c.i) / d; double newI = (i * c.r - r * c.i) / d; result.r = newR; result.i = newI; return result; }
java
{ "resource": "" }
q1601
Permutations.randomPermutation
train
public static int[] randomPermutation(int size) { Random r = new Random(); int[] result = new int[size]; for (int j = 0; j < size; j++) { result[j] = j; } for (int j = size - 1; j > 0; j--) { int k = r.nextInt(j); int temp = result[j]; result[j] = result[k]; result[k] = temp; } return result; }
java
{ "resource": "" }
q1602
Permutations.randomSubset
train
public static int[] randomSubset(int k, int n) { assert(0 < k && k <= n); Random r = new Random(); int t = 0, m = 0; int[] result = new int[k]; while (m < k) { double u = r.nextDouble(); if ( (n - t) * u < k - m ) { result[m] = t; m++; } t++; } return result; }
java
{ "resource": "" }
q1603
Singular.fullSVD
train
public static DoubleMatrix[] fullSVD(DoubleMatrix A) { int m = A.rows; int n = A.columns; DoubleMatrix U = new DoubleMatrix(m, m); DoubleMatrix S = new DoubleMatrix(min(m, n)); DoubleMatrix V = new DoubleMatrix(n, n); int info = NativeBlas.dgesvd('A', 'A', m, n, A.dup().data, 0, m, S.data, 0, U.data, 0, m, V.data, 0, n); if (info > 0) { throw new LapackConvergenceException("GESVD", info + " superdiagonals of an intermediate bidiagonal form failed to converge."); } return new DoubleMatrix[]{U, S, V.transpose()}; }
java
{ "resource": "" }
q1604
LibraryLoader.tryPath
train
private InputStream tryPath(String path) { Logger.getLogger().debug("Trying path \"" + path + "\"."); return getClass().getResourceAsStream(path); }
java
{ "resource": "" }
q1605
LibraryLoader.loadLibraryFromStream
train
private void loadLibraryFromStream(String libname, InputStream is) { try { File tempfile = createTempFile(libname); OutputStream os = new FileOutputStream(tempfile); logger.debug("tempfile.getPath() = " + tempfile.getPath()); long savedTime = System.currentTimeMillis(); // Leo says 8k block size is STANDARD ;) byte buf[] = new byte[8192]; int len; while ((len = is.read(buf)) > 0) { os.write(buf, 0, len); } os.flush(); InputStream lock = new FileInputStream(tempfile); os.close(); double seconds = (double) (System.currentTimeMillis() - savedTime) / 1e3; logger.debug("Copying took " + seconds + " seconds."); logger.debug("Loading library from " + tempfile.getPath() + "."); System.load(tempfile.getPath()); lock.close(); } catch (IOException io) { logger.error("Could not create the temp file: " + io.toString() + ".\n"); } catch (UnsatisfiedLinkError ule) { logger.error("Couldn't load copied link file: " + ule.toString() + ".\n"); throw ule; } }
java
{ "resource": "" }
q1606
SanityChecks.checkVectorAddition
train
public static void checkVectorAddition() { DoubleMatrix x = new DoubleMatrix(3, 1, 1.0, 2.0, 3.0); DoubleMatrix y = new DoubleMatrix(3, 1, 4.0, 5.0, 6.0); DoubleMatrix z = new DoubleMatrix(3, 1, 5.0, 7.0, 9.0); check("checking vector addition", x.add(y).equals(z)); }
java
{ "resource": "" }
q1607
SanityChecks.checkXerbla
train
public static void checkXerbla() { double[] x = new double[9]; System.out.println("Check whether we're catching XERBLA errors. If you see something like \"** On entry to DGEMM parameter number 4 had an illegal value\", it didn't work!"); try { NativeBlas.dgemm('N', 'N', 3, -1, 3, 1.0, x, 0, 3, x, 0, 3, 0.0, x, 0, 3); } catch (IllegalArgumentException e) { check("checking XERBLA", e.getMessage().contains("XERBLA")); return; } assert (false); // shouldn't happen }
java
{ "resource": "" }
q1608
SanityChecks.checkEigenvalues
train
public static void checkEigenvalues() { DoubleMatrix A = new DoubleMatrix(new double[][]{ {3.0, 2.0, 0.0}, {2.0, 3.0, 2.0}, {0.0, 2.0, 3.0} }); DoubleMatrix E = new DoubleMatrix(3, 1); NativeBlas.dsyev('N', 'U', 3, A.data, 0, 3, E.data, 0); check("checking existence of dsyev...", true); }
java
{ "resource": "" }
q1609
Decompose.cholesky
train
public static DoubleMatrix cholesky(DoubleMatrix A) { DoubleMatrix result = A.dup(); int info = NativeBlas.dpotrf('U', A.rows, result.data, 0, A.rows); if (info < 0) { throw new LapackArgumentException("DPOTRF", -info); } else if (info > 0) { throw new LapackPositivityException("DPOTRF", "Minor " + info + " was negative. Matrix must be positive definite."); } clearLower(result); return result; }
java
{ "resource": "" }
q1610
Decompose.qr
train
public static QRDecomposition<DoubleMatrix> qr(DoubleMatrix A) { int minmn = min(A.rows, A.columns); DoubleMatrix result = A.dup(); DoubleMatrix tau = new DoubleMatrix(minmn); SimpleBlas.geqrf(result, tau); DoubleMatrix R = new DoubleMatrix(A.rows, A.columns); for (int i = 0; i < A.rows; i++) { for (int j = i; j < A.columns; j++) { R.put(i, j, result.get(i, j)); } } DoubleMatrix Q = DoubleMatrix.eye(A.rows); SimpleBlas.ormqr('L', 'N', result, tau, Q); return new QRDecomposition<DoubleMatrix>(Q, R); }
java
{ "resource": "" }
q1611
MatrixFunctions.absi
train
public static DoubleMatrix absi(DoubleMatrix x) { /*# mapfct('Math.abs') #*/ //RJPP-BEGIN------------------------------------------------------------ for (int i = 0; i < x.length; i++) x.put(i, (double) Math.abs(x.get(i))); return x; //RJPP-END-------------------------------------------------------------- }
java
{ "resource": "" }
q1612
MatrixFunctions.expm
train
public static DoubleMatrix expm(DoubleMatrix A) { // constants for pade approximation final double c0 = 1.0; final double c1 = 0.5; final double c2 = 0.12; final double c3 = 0.01833333333333333; final double c4 = 0.0019927536231884053; final double c5 = 1.630434782608695E-4; final double c6 = 1.0351966873706E-5; final double c7 = 5.175983436853E-7; final double c8 = 2.0431513566525E-8; final double c9 = 6.306022705717593E-10; final double c10 = 1.4837700484041396E-11; final double c11 = 2.5291534915979653E-13; final double c12 = 2.8101705462199615E-15; final double c13 = 1.5440497506703084E-17; int j = Math.max(0, 1 + (int) Math.floor(Math.log(A.normmax()) / Math.log(2))); DoubleMatrix As = A.div((double) Math.pow(2, j)); // scaled version of A int n = A.getRows(); // calculate D and N using special Horner techniques DoubleMatrix As_2 = As.mmul(As); DoubleMatrix As_4 = As_2.mmul(As_2); DoubleMatrix As_6 = As_4.mmul(As_2); // U = c0*I + c2*A^2 + c4*A^4 + (c6*I + c8*A^2 + c10*A^4 + c12*A^6)*A^6 DoubleMatrix U = DoubleMatrix.eye(n).muli(c0).addi(As_2.mul(c2)).addi(As_4.mul(c4)).addi( DoubleMatrix.eye(n).muli(c6).addi(As_2.mul(c8)).addi(As_4.mul(c10)).addi(As_6.mul(c12)).mmuli(As_6)); // V = c1*I + c3*A^2 + c5*A^4 + (c7*I + c9*A^2 + c11*A^4 + c13*A^6)*A^6 DoubleMatrix V = DoubleMatrix.eye(n).muli(c1).addi(As_2.mul(c3)).addi(As_4.mul(c5)).addi( DoubleMatrix.eye(n).muli(c7).addi(As_2.mul(c9)).addi(As_4.mul(c11)).addi(As_6.mul(c13)).mmuli(As_6)); DoubleMatrix AV = As.mmuli(V); DoubleMatrix N = U.add(AV); DoubleMatrix D = U.subi(AV); // solve DF = N for F DoubleMatrix F = Solve.solve(D, N); // now square j times for (int k = 0; k < j; k++) { F.mmuli(F); } return F; }
java
{ "resource": "" }
q1613
JtsAdapter.toGeomType
train
public static VectorTile.Tile.GeomType toGeomType(Geometry geometry) { VectorTile.Tile.GeomType result = VectorTile.Tile.GeomType.UNKNOWN; if(geometry instanceof Point || geometry instanceof MultiPoint) { result = VectorTile.Tile.GeomType.POINT; } else if(geometry instanceof LineString || geometry instanceof MultiLineString) { result = VectorTile.Tile.GeomType.LINESTRING; } else if(geometry instanceof Polygon || geometry instanceof MultiPolygon) { result = VectorTile.Tile.GeomType.POLYGON; } return result; }
java
{ "resource": "" }
q1614
JtsAdapter.equalAsInts
train
private static boolean equalAsInts(Vec2d a, Vec2d b) { return ((int) a.x) == ((int) b.x) && ((int) a.y) == ((int) b.y); }
java
{ "resource": "" }
q1615
JtsLayer.validate
train
private static void validate(String name, Collection<Geometry> geometries, int extent) { if (name == null) { throw new IllegalArgumentException("layer name is null"); } if (geometries == null) { throw new IllegalArgumentException("geometry collection is null"); } if (extent <= 0) { throw new IllegalArgumentException("extent is less than or equal to 0"); } }
java
{ "resource": "" }
q1616
MvtLayerProps.addKey
train
public int addKey(String key) { JdkUtils.requireNonNull(key); int nextIndex = keys.size(); final Integer mapIndex = JdkUtils.putIfAbsent(keys, key, nextIndex); return mapIndex == null ? nextIndex : mapIndex; }
java
{ "resource": "" }
q1617
SwipeBackLayout.findScrollView
train
private void findScrollView(ViewGroup viewGroup) { scrollChild = viewGroup; if (viewGroup.getChildCount() > 0) { int count = viewGroup.getChildCount(); View child; for (int i = 0; i < count; i++) { child = viewGroup.getChildAt(i); if (child instanceof AbsListView || child instanceof ScrollView || child instanceof ViewPager || child instanceof WebView) { scrollChild = child; return; } } } }
java
{ "resource": "" }
q1618
CmsSendBroadcastDialog.removeAllBroadcasts
train
private void removeAllBroadcasts(Set<String> sessionIds) { if (sessionIds == null) { for (CmsSessionInfo info : OpenCms.getSessionManager().getSessionInfos()) { OpenCms.getSessionManager().getBroadcastQueue(info.getSessionId().getStringValue()).clear(); } return; } for (String sessionId : sessionIds) { OpenCms.getSessionManager().getBroadcastQueue(sessionId).clear(); } }
java
{ "resource": "" }
q1619
CmsPatternPanelMonthlyView.onWeekDayChange
train
@UiHandler("m_atDay") void onWeekDayChange(ValueChangeEvent<String> event) { if (handleChange()) { m_controller.setWeekDay(event.getValue()); } }
java
{ "resource": "" }
q1620
CmsPatternPanelMonthlyView.addCheckBox
train
private void addCheckBox(final String internalValue, String labelMessageKey) { CmsCheckBox box = new CmsCheckBox(Messages.get().key(labelMessageKey)); box.setInternalValue(internalValue); box.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (handleChange()) { m_controller.weeksChange(internalValue, event.getValue()); } } }); m_weekPanel.add(box); m_checkboxes.add(box); }
java
{ "resource": "" }
q1621
CmsPatternPanelMonthlyView.checkExactlyTheWeeksCheckBoxes
train
private void checkExactlyTheWeeksCheckBoxes(Collection<WeekOfMonth> weeksToCheck) { for (CmsCheckBox cb : m_checkboxes) { cb.setChecked(weeksToCheck.contains(WeekOfMonth.valueOf(cb.getInternalValue()))); } }
java
{ "resource": "" }
q1622
CmsPatternPanelMonthlyView.fillWeekPanel
train
private void fillWeekPanel() { addCheckBox(WeekOfMonth.FIRST.toString(), Messages.GUI_SERIALDATE_WEEKDAYNUMBER_1_0); addCheckBox(WeekOfMonth.SECOND.toString(), Messages.GUI_SERIALDATE_WEEKDAYNUMBER_2_0); addCheckBox(WeekOfMonth.THIRD.toString(), Messages.GUI_SERIALDATE_WEEKDAYNUMBER_3_0); addCheckBox(WeekOfMonth.FOURTH.toString(), Messages.GUI_SERIALDATE_WEEKDAYNUMBER_4_0); addCheckBox(WeekOfMonth.LAST.toString(), Messages.GUI_SERIALDATE_WEEKDAYNUMBER_5_0); }
java
{ "resource": "" }
q1623
A_CmsSetupStep.htmlLabel
train
public Label htmlLabel(String html) { Label label = new Label(); label.setContentMode(ContentMode.HTML); label.setValue(html); return label; }
java
{ "resource": "" }
q1624
A_CmsSetupStep.readSnippet
train
public String readSnippet(String name) { String path = CmsStringUtil.joinPaths( m_context.getSetupBean().getWebAppRfsPath(), CmsSetupBean.FOLDER_SETUP, "html", name); try (InputStream stream = new FileInputStream(path)) { byte[] data = CmsFileUtil.readFully(stream, false); String result = new String(data, "UTF-8"); return result; } catch (Exception e) { throw new RuntimeException(e); } }
java
{ "resource": "" }
q1625
CmsAddFormatterWidget.getSelectOptionValues
train
public static List<String> getSelectOptionValues(CmsObject cms, String rootPath, boolean allRemoved) { try { cms = OpenCms.initCmsObject(cms); cms.getRequestContext().setSiteRoot(""); CmsADEConfigData adeConfig = OpenCms.getADEManager().lookupConfiguration(cms, rootPath); if (adeConfig.parent() != null) { adeConfig = adeConfig.parent(); } List<CmsSelectWidgetOption> options = getFormatterOptionsStatic(cms, adeConfig, rootPath, allRemoved); List<CmsSelectWidgetOption> typeOptions = getTypeOptionsStatic(cms, adeConfig, allRemoved); options.addAll(typeOptions); List<String> result = new ArrayList<String>(options.size()); for (CmsSelectWidgetOption o : options) { result.add(o.getValue()); } return result; } catch (CmsException e) { // should never happen LOG.error(e.getLocalizedMessage(), e); return null; } }
java
{ "resource": "" }
q1626
CmsEditableGroup.addRow
train
public void addRow(Component component) { Component actualComponent = component == null ? m_newComponentFactory.get() : component; I_CmsEditableGroupRow row = m_rowBuilder.buildRow(this, actualComponent); m_container.addComponent(row); updatePlaceholder(); updateButtonBars(); updateGroupValidation(); }
java
{ "resource": "" }
q1627
CmsEditableGroup.addRowAfter
train
public void addRowAfter(I_CmsEditableGroupRow row) { int index = m_container.getComponentIndex(row); if (index >= 0) { Component component = m_newComponentFactory.get(); I_CmsEditableGroupRow newRow = m_rowBuilder.buildRow(this, component); m_container.addComponent(newRow, index + 1); } updatePlaceholder(); updateButtonBars(); updateGroupValidation(); }
java
{ "resource": "" }
q1628
CmsEditableGroup.getRows
train
public List<I_CmsEditableGroupRow> getRows() { List<I_CmsEditableGroupRow> result = Lists.newArrayList(); for (Component component : m_container) { if (component instanceof I_CmsEditableGroupRow) { result.add((I_CmsEditableGroupRow)component); } } return result; }
java
{ "resource": "" }
q1629
CmsEditableGroup.moveDown
train
public void moveDown(I_CmsEditableGroupRow row) { int index = m_container.getComponentIndex(row); if ((index >= 0) && (index < (m_container.getComponentCount() - 1))) { m_container.removeComponent(row); m_container.addComponent(row, index + 1); } updateButtonBars(); }
java
{ "resource": "" }
q1630
CmsEditableGroup.moveUp
train
public void moveUp(I_CmsEditableGroupRow row) { int index = m_container.getComponentIndex(row); if (index > 0) { m_container.removeComponent(row); m_container.addComponent(row, index - 1); } updateButtonBars(); }
java
{ "resource": "" }
q1631
CmsEditableGroup.remove
train
public void remove(I_CmsEditableGroupRow row) { int index = m_container.getComponentIndex(row); if (index >= 0) { m_container.removeComponent(row); } updatePlaceholder(); updateButtonBars(); updateGroupValidation(); }
java
{ "resource": "" }
q1632
CmsObject.adjustLinks
train
public void adjustLinks(String sourceFolder, String targetFolder) throws CmsException { String rootSourceFolder = addSiteRoot(sourceFolder); String rootTargetFolder = addSiteRoot(targetFolder); String siteRoot = getRequestContext().getSiteRoot(); getRequestContext().setSiteRoot(""); try { CmsLinkRewriter linkRewriter = new CmsLinkRewriter(this, rootSourceFolder, rootTargetFolder); linkRewriter.rewriteLinks(); } finally { getRequestContext().setSiteRoot(siteRoot); } }
java
{ "resource": "" }
q1633
CmsColorSelector.setRGB
train
public void setRGB(int red, int green, int blue) throws Exception { CmsColor color = new CmsColor(); color.setRGB(red, green, blue); m_red = red; m_green = green; m_blue = blue; m_hue = color.getHue(); m_saturation = color.getSaturation(); m_brightness = color.getValue(); m_tbRed.setText(Integer.toString(m_red)); m_tbGreen.setText(Integer.toString(m_green)); m_tbBlue.setText(Integer.toString(m_blue)); m_tbHue.setText(Integer.toString(m_hue)); m_tbSaturation.setText(Integer.toString(m_saturation)); m_tbBrightness.setText(Integer.toString(m_brightness)); m_tbHexColor.setText(color.getHex()); setPreview(color.getHex()); updateSliders(); }
java
{ "resource": "" }
q1634
CmsFavoriteDialog.doSave
train
protected void doSave() { List<CmsFavoriteEntry> entries = getEntries(); try { m_favDao.saveFavorites(entries); } catch (Exception e) { CmsErrorDialog.showErrorDialog(e); } }
java
{ "resource": "" }
q1635
CmsFavoriteDialog.getEntries
train
List<CmsFavoriteEntry> getEntries() { List<CmsFavoriteEntry> result = new ArrayList<>(); for (I_CmsEditableGroupRow row : m_group.getRows()) { CmsFavoriteEntry entry = ((CmsFavInfo)row).getEntry(); result.add(entry); } return result; }
java
{ "resource": "" }
q1636
CmsFavoriteDialog.createFavInfo
train
private CmsFavInfo createFavInfo(CmsFavoriteEntry entry) throws CmsException { String title = ""; String subtitle = ""; CmsFavInfo result = new CmsFavInfo(entry); CmsObject cms = A_CmsUI.getCmsObject(); String project = getProject(cms, entry); String site = getSite(cms, entry); try { CmsUUID idToLoad = entry.getDetailId() != null ? entry.getDetailId() : entry.getStructureId(); CmsResource resource = cms.readResource(idToLoad, CmsResourceFilter.IGNORE_EXPIRATION.addRequireVisible()); CmsResourceUtil resutil = new CmsResourceUtil(cms, resource); switch (entry.getType()) { case explorerFolder: title = CmsStringUtil.isEmpty(resutil.getTitle()) ? CmsResource.getName(resource.getRootPath()) : resutil.getTitle(); break; case page: title = resutil.getTitle(); break; } subtitle = resource.getRootPath(); CmsResourceIcon icon = result.getResourceIcon(); icon.initContent(resutil, CmsResource.STATE_UNCHANGED, false, false); } catch (CmsException e) { LOG.warn(e.getLocalizedMessage(), e); } result.getTopLine().setValue(title); result.getBottomLine().setValue(subtitle); result.getProjectLabel().setValue(project); result.getSiteLabel().setValue(site); return result; }
java
{ "resource": "" }
q1637
CmsFavoriteDialog.getEntry
train
private CmsFavoriteEntry getEntry(Component row) { if (row instanceof CmsFavInfo) { return ((CmsFavInfo)row).getEntry(); } return null; }
java
{ "resource": "" }
q1638
CmsFavoriteDialog.getProject
train
private String getProject(CmsObject cms, CmsFavoriteEntry entry) throws CmsException { String result = m_projectLabels.get(entry.getProjectId()); if (result == null) { result = cms.readProject(entry.getProjectId()).getName(); m_projectLabels.put(entry.getProjectId(), result); } return result; }
java
{ "resource": "" }
q1639
CmsFavoriteDialog.getSite
train
private String getSite(CmsObject cms, CmsFavoriteEntry entry) { CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(entry.getSiteRoot()); Item item = m_sitesContainer.getItem(entry.getSiteRoot()); if (item != null) { return (String)(item.getItemProperty("caption").getValue()); } String result = entry.getSiteRoot(); if (site != null) { if (!CmsStringUtil.isEmpty(site.getTitle())) { result = site.getTitle(); } } return result; }
java
{ "resource": "" }
q1640
CmsFavoriteDialog.onClickAdd
train
private void onClickAdd() { if (m_currentLocation.isPresent()) { CmsFavoriteEntry entry = m_currentLocation.get(); List<CmsFavoriteEntry> entries = getEntries(); entries.add(entry); try { m_favDao.saveFavorites(entries); } catch (Exception e) { CmsErrorDialog.showErrorDialog(e); } m_context.close(); } }
java
{ "resource": "" }
q1641
CmsJspTagNavigation.setLocale
train
public void setLocale(String locale) { try { m_locale = LocaleUtils.toLocale(locale); } catch (IllegalArgumentException e) { LOG.error(Messages.get().getBundle().key(Messages.ERR_TAG_INVALID_LOCALE_1, "cms:navigation"), e); m_locale = null; } }
java
{ "resource": "" }
q1642
CmsFavoriteDAO.loadFavorites
train
public List<CmsFavoriteEntry> loadFavorites() throws CmsException { List<CmsFavoriteEntry> result = new ArrayList<>(); try { CmsUser user = readUser(); String data = (String)user.getAdditionalInfo(ADDINFO_KEY); if (CmsStringUtil.isEmptyOrWhitespaceOnly(data)) { return new ArrayList<>(); } JSONObject json = new JSONObject(data); JSONArray array = json.getJSONArray(BASE_KEY); for (int i = 0; i < array.length(); i++) { JSONObject fav = array.getJSONObject(i); try { CmsFavoriteEntry entry = new CmsFavoriteEntry(fav); if (validate(entry)) { result.add(entry); } } catch (Exception e) { LOG.warn(e.getLocalizedMessage(), e); } } } catch (JSONException e) { LOG.error(e.getLocalizedMessage(), e); } return result; }
java
{ "resource": "" }
q1643
CmsFavoriteDAO.saveFavorites
train
public void saveFavorites(List<CmsFavoriteEntry> favorites) throws CmsException { try { JSONObject json = new JSONObject(); JSONArray array = new JSONArray(); for (CmsFavoriteEntry entry : favorites) { array.put(entry.toJson()); } json.put(BASE_KEY, array); String data = json.toString(); CmsUser user = readUser(); user.setAdditionalInfo(ADDINFO_KEY, data); m_cms.writeUser(user); } catch (JSONException e) { LOG.error(e.getLocalizedMessage(), e); } }
java
{ "resource": "" }
q1644
CmsFavoriteDAO.validate
train
private boolean validate(CmsFavoriteEntry entry) { try { String siteRoot = entry.getSiteRoot(); if (!m_okSiteRoots.contains(siteRoot)) { m_rootCms.readResource(siteRoot); m_okSiteRoots.add(siteRoot); } CmsUUID project = entry.getProjectId(); if (!m_okProjects.contains(project)) { m_cms.readProject(project); m_okProjects.add(project); } for (CmsUUID id : Arrays.asList(entry.getDetailId(), entry.getStructureId())) { if ((id != null) && !m_okStructureIds.contains(id)) { m_cms.readResource(id, CmsResourceFilter.IGNORE_EXPIRATION.addRequireVisible()); m_okStructureIds.add(id); } } return true; } catch (Exception e) { LOG.info("Favorite entry validation failed: " + e.getLocalizedMessage(), e); return false; } }
java
{ "resource": "" }
q1645
CmsSerialDateView.showCurrentDates
train
public void showCurrentDates(Collection<CmsPair<Date, Boolean>> dates) { m_overviewList.setDatesWithCheckState(dates); m_overviewPopup.center(); }
java
{ "resource": "" }
q1646
CmsSerialDateView.updateExceptions
train
public void updateExceptions() { m_exceptionsList.setDates(m_model.getExceptions()); if (m_model.getExceptions().size() > 0) { m_exceptionsPanel.setVisible(true); } else { m_exceptionsPanel.setVisible(false); } }
java
{ "resource": "" }
q1647
CmsSerialDateView.onCurrentTillEndChange
train
@UiHandler("m_currentTillEndCheckBox") void onCurrentTillEndChange(ValueChangeEvent<Boolean> event) { if (handleChange()) { m_controller.setCurrentTillEnd(event.getValue()); } }
java
{ "resource": "" }
q1648
CmsSerialDateView.onEndTimeChange
train
@UiHandler("m_endTime") void onEndTimeChange(CmsDateBoxEvent event) { if (handleChange() && !event.isUserTyping()) { m_controller.setEndTime(event.getDate()); } }
java
{ "resource": "" }
q1649
CmsSerialDateView.onEndTypeChange
train
void onEndTypeChange() { EndType endType = m_model.getEndType(); m_groupDuration.selectButton(getDurationButtonForType(endType)); switch (endType) { case DATE: case TIMES: m_durationPanel.setVisible(true); m_seriesEndDate.setValue(m_model.getSeriesEndDate()); int occurrences = m_model.getOccurrences(); if (!m_occurrences.isFocused()) { m_occurrences.setFormValueAsString(occurrences > 0 ? "" + occurrences : ""); } break; default: m_durationPanel.setVisible(false); break; } updateExceptions(); }
java
{ "resource": "" }
q1650
CmsSerialDateView.onPatternChange
train
void onPatternChange() { PatternType patternType = m_model.getPatternType(); boolean isSeries = !patternType.equals(PatternType.NONE); setSerialOptionsVisible(isSeries); m_seriesCheckBox.setChecked(isSeries); if (isSeries) { m_groupPattern.selectButton(m_patternButtons.get(patternType)); m_controller.getPatternView().onValueChange(); m_patternOptions.setWidget(m_controller.getPatternView()); onEndTypeChange(); } m_controller.sizeChanged(); }
java
{ "resource": "" }
q1651
CmsSerialDateView.onSeriesChange
train
@UiHandler("m_seriesCheckBox") void onSeriesChange(ValueChangeEvent<Boolean> event) { if (handleChange()) { m_controller.setIsSeries(event.getValue()); } }
java
{ "resource": "" }
q1652
CmsSerialDateView.onStartTimeChange
train
@UiHandler("m_startTime") void onStartTimeChange(CmsDateBoxEvent event) { if (handleChange() && !event.isUserTyping()) { m_controller.setStartTime(event.getDate()); } }
java
{ "resource": "" }
q1653
CmsSerialDateView.onWholeDayChange
train
@UiHandler("m_wholeDayCheckBox") void onWholeDayChange(ValueChangeEvent<Boolean> event) { //TODO: Improve - adjust time selections? if (handleChange()) { m_controller.setWholeDay(event.getValue()); } }
java
{ "resource": "" }
q1654
CmsSerialDateView.createAndAddButton
train
private void createAndAddButton(PatternType pattern, String messageKey) { CmsRadioButton btn = new CmsRadioButton(pattern.toString(), Messages.get().key(messageKey)); btn.addStyleName(I_CmsWidgetsLayoutBundle.INSTANCE.widgetCss().radioButtonlabel()); btn.setGroup(m_groupPattern); m_patternButtons.put(pattern, btn); m_patternRadioButtonsPanel.add(btn); }
java
{ "resource": "" }
q1655
CmsSerialDateView.initDatesPanel
train
private void initDatesPanel() { m_startLabel.setText(Messages.get().key(Messages.GUI_SERIALDATE_TIME_STARTTIME_0)); m_startTime.setAllowInvalidValue(true); m_startTime.setValue(m_model.getStart()); m_endLabel.setText(Messages.get().key(Messages.GUI_SERIALDATE_TIME_ENDTIME_0)); m_endTime.setAllowInvalidValue(true); m_endTime.setValue(m_model.getEnd()); m_seriesCheckBox.setText(Messages.get().key(Messages.GUI_SERIALDATE_SERIES_CHECKBOX_0)); m_wholeDayCheckBox.setText(Messages.get().key(Messages.GUI_SERIALDATE_WHOLE_DAY_CHECKBOX_0)); m_currentTillEndCheckBox.setText(Messages.get().key(Messages.GUI_SERIALDATE_CURRENT_TILL_END_CHECKBOX_0)); m_currentTillEndCheckBox.getButton().setTitle( Messages.get().key(Messages.GUI_SERIALDATE_CURRENT_TILL_END_CHECKBOX_HELP_0)); }
java
{ "resource": "" }
q1656
CmsSerialDateView.initDeactivationPanel
train
private void initDeactivationPanel() { m_deactivationPanel.setVisible(false); m_deactivationText.setText(Messages.get().key(Messages.GUI_SERIALDATE_DEACTIVE_TEXT_0)); }
java
{ "resource": "" }
q1657
CmsSerialDateView.initDurationButtonGroup
train
private void initDurationButtonGroup() { m_groupDuration = new CmsRadioButtonGroup(); m_endsAfterRadioButton = new CmsRadioButton( EndType.TIMES.toString(), Messages.get().key(Messages.GUI_SERIALDATE_DURATION_ENDTYPE_OCC_0)); m_endsAfterRadioButton.setGroup(m_groupDuration); m_endsAtRadioButton = new CmsRadioButton( EndType.DATE.toString(), Messages.get().key(Messages.GUI_SERIALDATE_DURATION_ENDTYPE_DATE_0)); m_endsAtRadioButton.setGroup(m_groupDuration); m_groupDuration.addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> event) { if (handleChange()) { String value = event.getValue(); if (null != value) { m_controller.setEndType(value); } } } }); }
java
{ "resource": "" }
q1658
CmsSerialDateView.initDurationPanel
train
private void initDurationPanel() { m_durationPrefixLabel.setText(Messages.get().key(Messages.GUI_SERIALDATE_DURATION_PREFIX_0)); m_durationAfterPostfixLabel.setText(Messages.get().key(Messages.GUI_SERIALDATE_DURATION_ENDTYPE_OCC_POSTFIX_0)); m_seriesEndDate.setDateOnly(true); m_seriesEndDate.setAllowInvalidValue(true); m_seriesEndDate.setValue(m_model.getSeriesEndDate()); m_seriesEndDate.getTextField().addFocusHandler(new FocusHandler() { public void onFocus(FocusEvent event) { if (handleChange()) { onSeriesEndDateFocus(event); } } }); }
java
{ "resource": "" }
q1659
CmsSerialDateView.initExceptionsPanel
train
private void initExceptionsPanel() { m_exceptionsPanel.setLegend(Messages.get().key(Messages.GUI_SERIALDATE_PANEL_EXCEPTIONS_0)); m_exceptionsPanel.addCloseHandler(this); m_exceptionsPanel.setVisible(false); }
java
{ "resource": "" }
q1660
CmsSerialDateView.initManagementPart
train
private void initManagementPart() { m_manageExceptionsButton.setText(Messages.get().key(Messages.GUI_SERIALDATE_BUTTON_MANAGE_EXCEPTIONS_0)); m_manageExceptionsButton.getElement().getStyle().setFloat(Style.Float.RIGHT); }
java
{ "resource": "" }
q1661
CmsSerialDateView.initPatternButtonGroup
train
private void initPatternButtonGroup() { m_groupPattern = new CmsRadioButtonGroup(); m_patternButtons = new HashMap<>(); createAndAddButton(PatternType.DAILY, Messages.GUI_SERIALDATE_TYPE_DAILY_0); m_patternButtons.put(PatternType.NONE, m_patternButtons.get(PatternType.DAILY)); createAndAddButton(PatternType.WEEKLY, Messages.GUI_SERIALDATE_TYPE_WEEKLY_0); createAndAddButton(PatternType.MONTHLY, Messages.GUI_SERIALDATE_TYPE_MONTHLY_0); createAndAddButton(PatternType.YEARLY, Messages.GUI_SERIALDATE_TYPE_YEARLY_0); // createAndAddButton(PatternType.INDIVIDUAL, Messages.GUI_SERIALDATE_TYPE_INDIVIDUAL_0); m_groupPattern.addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> event) { if (handleChange()) { String value = event.getValue(); if (value != null) { m_controller.setPattern(value); } } } }); }
java
{ "resource": "" }
q1662
CmsAppView.injectAdditionalStyles
train
private void injectAdditionalStyles() { try { Collection<String> stylesheets = OpenCms.getWorkplaceAppManager().getAdditionalStyleSheets(); for (String stylesheet : stylesheets) { A_CmsUI.get().getPage().addDependency(new Dependency(Type.STYLESHEET, stylesheet)); } } catch (Exception e) { LOG.warn(e.getLocalizedMessage(), e); } }
java
{ "resource": "" }
q1663
CmsUgcActionElement.createSessionForResource
train
public String createSessionForResource(String configPath, String fileName) throws CmsUgcException { CmsUgcSession formSession = CmsUgcSessionFactory.getInstance().createSessionForFile( getCmsObject(), getRequest(), configPath, fileName); return "" + formSession.getId(); }
java
{ "resource": "" }
q1664
CmsSerialDateValue.setValue
train
public final void setValue(String value) { if ((null == value) || value.isEmpty()) { setDefaultValue(); } else { try { tryToSetParsedValue(value); } catch (@SuppressWarnings("unused") Exception e) { CmsDebugLog.consoleLog("Could not set invalid serial date value: " + value); setDefaultValue(); } } notifyOnValueChange(); }
java
{ "resource": "" }
q1665
CmsSerialDateValue.datesToJsonArray
train
private JSONValue datesToJsonArray(Collection<Date> dates) { if (null != dates) { JSONArray result = new JSONArray(); for (Date d : dates) { result.set(result.size(), dateToJson(d)); } return result; } return null; }
java
{ "resource": "" }
q1666
CmsSerialDateValue.dateToJson
train
private JSONValue dateToJson(Date d) { return null != d ? new JSONString(Long.toString(d.getTime())) : null; }
java
{ "resource": "" }
q1667
CmsSerialDateValue.readOptionalBoolean
train
private Boolean readOptionalBoolean(JSONValue val) { JSONBoolean b = null == val ? null : val.isBoolean(); if (b != null) { return Boolean.valueOf(b.booleanValue()); } return null; }
java
{ "resource": "" }
q1668
CmsSerialDateValue.readOptionalDate
train
private Date readOptionalDate(JSONValue val) { JSONString str = null == val ? null : val.isString(); if (str != null) { try { return new Date(Long.parseLong(str.stringValue())); } catch (@SuppressWarnings("unused") NumberFormatException e) { // do nothing - return the default value } } return null; }
java
{ "resource": "" }
q1669
CmsSerialDateValue.readOptionalInt
train
private int readOptionalInt(JSONValue val) { JSONString str = null == val ? null : val.isString(); if (str != null) { try { return Integer.valueOf(str.stringValue()).intValue(); } catch (@SuppressWarnings("unused") NumberFormatException e) { // Do nothing, return default value } } return 0; }
java
{ "resource": "" }
q1670
CmsSerialDateValue.readOptionalMonth
train
private Month readOptionalMonth(JSONValue val) { String str = readOptionalString(val); if (null != str) { try { return Month.valueOf(str); } catch (@SuppressWarnings("unused") IllegalArgumentException e) { // Do nothing -return the default value } } return null; }
java
{ "resource": "" }
q1671
CmsSerialDateValue.readOptionalString
train
private String readOptionalString(JSONValue val) { JSONString str = null == val ? null : val.isString(); if (str != null) { return str.stringValue(); } return null; }
java
{ "resource": "" }
q1672
CmsSerialDateValue.readWeekDay
train
private WeekDay readWeekDay(JSONValue val) throws IllegalArgumentException { String str = readOptionalString(val); if (null != str) { return WeekDay.valueOf(str); } throw new IllegalArgumentException(); }
java
{ "resource": "" }
q1673
CmsSerialDateValue.toJsonStringList
train
private JSONValue toJsonStringList(Collection<? extends Object> list) { if (null != list) { JSONArray array = new JSONArray(); for (Object o : list) { array.set(array.size(), new JSONString(o.toString())); } return array; } else { return null; } }
java
{ "resource": "" }
q1674
CmsSerialDateValue.tryToSetParsedValue
train
private void tryToSetParsedValue(String value) throws Exception { JSONObject json = JSONParser.parseStrict(value).isObject(); JSONValue val = json.get(JsonKey.START); setStart(readOptionalDate(val)); val = json.get(JsonKey.END); setEnd(readOptionalDate(val)); setWholeDay(readOptionalBoolean(json.get(JsonKey.WHOLE_DAY))); JSONObject patternJson = json.get(JsonKey.PATTERN).isObject(); readPattern(patternJson); setExceptions(readDates(json.get(JsonKey.EXCEPTIONS))); setSeriesEndDate(readOptionalDate(json.get(JsonKey.SERIES_ENDDATE))); setOccurrences(readOptionalInt(json.get(JsonKey.SERIES_OCCURRENCES))); setDerivedEndType(); setCurrentTillEnd(readOptionalBoolean(json.get(JsonKey.CURRENT_TILL_END))); setParentSeriesId(readOptionalUUID(json.get(JsonKey.PARENT_SERIES))); }
java
{ "resource": "" }
q1675
CmsJspCategoryAccessBean.getCategories
train
private static List<CmsCategory> getCategories(CmsObject cms, CmsResource resource) { if ((null != resource) && (null != cms)) { try { return CmsCategoryService.getInstance().readResourceCategories(cms, resource); } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } } return new ArrayList<CmsCategory>(0); }
java
{ "resource": "" }
q1676
CmsJspCategoryAccessBean.getLeafItems
train
public List<CmsCategory> getLeafItems() { List<CmsCategory> result = new ArrayList<CmsCategory>(); if (m_categories.isEmpty()) { return result; } Iterator<CmsCategory> it = m_categories.iterator(); CmsCategory current = it.next(); while (it.hasNext()) { CmsCategory next = it.next(); if (!next.getPath().startsWith(current.getPath())) { result.add(current); } current = next; } result.add(current); return result; }
java
{ "resource": "" }
q1677
CmsJspCategoryAccessBean.getSubCategories
train
public Map<String, CmsJspCategoryAccessBean> getSubCategories() { if (m_subCategories == null) { m_subCategories = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() { @SuppressWarnings("synthetic-access") public Object transform(Object pathPrefix) { return new CmsJspCategoryAccessBean(m_cms, m_categories, (String)pathPrefix); } }); } return m_subCategories; }
java
{ "resource": "" }
q1678
CmsJspCategoryAccessBean.getTopItems
train
public List<CmsCategory> getTopItems() { List<CmsCategory> categories = new ArrayList<CmsCategory>(); String matcher = Pattern.quote(m_mainCategoryPath) + "[^/]*/"; for (CmsCategory category : m_categories) { if (category.getPath().matches(matcher)) { categories.add(category); } } return categories; }
java
{ "resource": "" }
q1679
CmsJspImageBean.addHiDpiImage
train
public void addHiDpiImage(String factor, CmsJspImageBean image) { if (m_hiDpiImages == null) { m_hiDpiImages = CmsCollectionsGenericWrapper.createLazyMap(new CmsScaleHiDpiTransformer()); } m_hiDpiImages.put(factor, image); }
java
{ "resource": "" }
q1680
CmsGallerySearchResult.getRequiredSolrFields
train
public static final String[] getRequiredSolrFields() { if (null == m_requiredSolrFields) { List<Locale> locales = OpenCms.getLocaleManager().getAvailableLocales(); m_requiredSolrFields = new String[14 + (locales.size() * 6)]; int count = 0; m_requiredSolrFields[count++] = CmsSearchField.FIELD_PATH; m_requiredSolrFields[count++] = CmsSearchField.FIELD_TYPE; m_requiredSolrFields[count++] = CmsSearchField.FIELD_DATE_CREATED; m_requiredSolrFields[count++] = CmsSearchField.FIELD_DATE_LASTMODIFIED; m_requiredSolrFields[count++] = CmsSearchField.FIELD_DATE_EXPIRED; m_requiredSolrFields[count++] = CmsSearchField.FIELD_DATE_RELEASED; m_requiredSolrFields[count++] = CmsSearchField.FIELD_SIZE; m_requiredSolrFields[count++] = CmsSearchField.FIELD_STATE; m_requiredSolrFields[count++] = CmsSearchField.FIELD_USER_CREATED; m_requiredSolrFields[count++] = CmsSearchField.FIELD_ID; m_requiredSolrFields[count++] = CmsSearchField.FIELD_USER_LAST_MODIFIED; m_requiredSolrFields[count++] = CmsSearchField.FIELD_ADDITIONAL_INFO; m_requiredSolrFields[count++] = CmsSearchField.FIELD_CONTAINER_TYPES; m_requiredSolrFields[count++] = CmsSearchField.FIELD_RESOURCE_LOCALES; for (Locale locale : locales) { m_requiredSolrFields[count++] = CmsSearchFieldConfiguration.getLocaleExtendedName( CmsSearchField.FIELD_TITLE_UNSTORED, locale.toString()) + "_s"; m_requiredSolrFields[count++] = CmsSearchFieldConfiguration.getLocaleExtendedName( CmsPropertyDefinition.PROPERTY_TITLE, locale.toString()) + CmsSearchField.FIELD_DYNAMIC_PROPERTIES_DIRECT + "_s"; m_requiredSolrFields[count++] = CmsPropertyDefinition.PROPERTY_TITLE + CmsSearchField.FIELD_DYNAMIC_PROPERTIES_DIRECT + "_s"; m_requiredSolrFields[count++] = CmsSearchFieldConfiguration.getLocaleExtendedName( CmsSearchField.FIELD_DESCRIPTION, locale.toString()) + "_s"; m_requiredSolrFields[count++] = CmsSearchFieldConfiguration.getLocaleExtendedName( CmsPropertyDefinition.PROPERTY_DESCRIPTION, locale.toString()) + CmsSearchField.FIELD_DYNAMIC_PROPERTIES + "_s"; m_requiredSolrFields[count++] = CmsPropertyDefinition.PROPERTY_DESCRIPTION + CmsSearchField.FIELD_DYNAMIC_PROPERTIES + "_s"; } } return m_requiredSolrFields; }
java
{ "resource": "" }
q1681
CmsPageEditorFavoriteContext.toUuid
train
private static CmsUUID toUuid(String uuid) { if ("null".equals(uuid) || CmsStringUtil.isEmpty(uuid)) { return null; } return new CmsUUID(uuid); }
java
{ "resource": "" }
q1682
CmsSearchManager.ensureIndexIsUnlocked
train
private void ensureIndexIsUnlocked(String dataDir) { Collection<File> lockFiles = new ArrayList<File>(2); lockFiles.add( new File( CmsFileUtil.addTrailingSeparator(CmsFileUtil.addTrailingSeparator(dataDir) + "index") + "write.lock")); lockFiles.add( new File( CmsFileUtil.addTrailingSeparator(CmsFileUtil.addTrailingSeparator(dataDir) + "spellcheck") + "write.lock")); for (File lockFile : lockFiles) { if (lockFile.exists()) { lockFile.delete(); LOG.warn( "Forcely unlocking index with data dir \"" + dataDir + "\" by removing file \"" + lockFile.getAbsolutePath() + "\"."); } } }
java
{ "resource": "" }
q1683
CmsScrollPanelImpl.maybeUpdateScrollbarPositions
train
private void maybeUpdateScrollbarPositions() { if (!isAttached()) { return; } if (m_scrollbar != null) { int vPos = getVerticalScrollPosition(); if (m_scrollbar.getVerticalScrollPosition() != vPos) { m_scrollbar.setVerticalScrollPosition(vPos); } } }
java
{ "resource": "" }
q1684
CmsScrollPanelImpl.setVerticalScrollbar
train
private void setVerticalScrollbar(final CmsScrollBar scrollbar, int width) { // Validate. if ((scrollbar == m_scrollbar) || (scrollbar == null)) { return; } // Detach new child. scrollbar.asWidget().removeFromParent(); // Remove old child. if (m_scrollbar != null) { if (m_verticalScrollbarHandlerRegistration != null) { m_verticalScrollbarHandlerRegistration.removeHandler(); m_verticalScrollbarHandlerRegistration = null; } remove(m_scrollbar); } m_scrollLayer.appendChild(scrollbar.asWidget().getElement()); adopt(scrollbar.asWidget()); // Logical attach. m_scrollbar = scrollbar; m_verticalScrollbarWidth = width; // Initialize the new scrollbar. m_verticalScrollbarHandlerRegistration = scrollbar.addValueChangeHandler(new ValueChangeHandler<Integer>() { public void onValueChange(ValueChangeEvent<Integer> event) { int vPos = scrollbar.getVerticalScrollPosition(); int v = getVerticalScrollPosition(); if (v != vPos) { setVerticalScrollPosition(vPos); } } }); maybeUpdateScrollbars(); }
java
{ "resource": "" }
q1685
UAgentInfo.detectBlackBerryHigh
train
public boolean detectBlackBerryHigh() { //Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser if (detectBlackBerryWebKit()) { return false; } if (detectBlackBerry()) { if (detectBlackBerryTouch() || (userAgent.indexOf(deviceBBBold) != -1) || (userAgent.indexOf(deviceBBTour) != -1) || (userAgent.indexOf(deviceBBCurve) != -1)) { return true; } else { return false; } } else { return false; } }
java
{ "resource": "" }
q1686
UAgentInfo.detectBlackBerryTouch
train
public boolean detectBlackBerryTouch() { if (detectBlackBerry() && ((userAgent.indexOf(deviceBBStorm) != -1) || (userAgent.indexOf(deviceBBTorch) != -1) || (userAgent.indexOf(deviceBBBoldTouch) != -1) || (userAgent.indexOf(deviceBBCurveTouch) != -1))) { return true; } return false; }
java
{ "resource": "" }
q1687
UAgentInfo.detectMobileQuick
train
public boolean detectMobileQuick() { //Let's exclude tablets if (isTierTablet) { return false; } //Most mobile browsing is done on smartphones if (detectSmartphone()) { return true; } //Catch-all for many mobile devices if (userAgent.indexOf(mobile) != -1) { return true; } if (detectOperaMobile()) { return true; } //We also look for Kindle devices if (detectKindle() || detectAmazonSilk()) { return true; } if (detectWapWml() || detectMidpCapable() || detectBrewDevice()) { return true; } if ((userAgent.indexOf(engineNetfront) != -1) || (userAgent.indexOf(engineUpBrowser) != -1)) { return true; } return false; }
java
{ "resource": "" }
q1688
UAgentInfo.detectNintendo
train
public boolean detectNintendo() { if ((userAgent.indexOf(deviceNintendo) != -1) || (userAgent.indexOf(deviceWii) != -1) || (userAgent.indexOf(deviceNintendoDs) != -1)) { return true; } return false; }
java
{ "resource": "" }
q1689
UAgentInfo.detectOperaMobile
train
public boolean detectOperaMobile() { if ((userAgent.indexOf(engineOpera) != -1) && ((userAgent.indexOf(mini) != -1) || (userAgent.indexOf(mobi) != -1))) { return true; } return false; }
java
{ "resource": "" }
q1690
UAgentInfo.detectSonyMylo
train
public boolean detectSonyMylo() { if ((userAgent.indexOf(manuSony) != -1) && ((userAgent.indexOf(qtembedded) != -1) || (userAgent.indexOf(mylocom2) != -1))) { return true; } return false; }
java
{ "resource": "" }
q1691
UAgentInfo.detectTierIphone
train
public boolean detectTierIphone() { if (detectIphoneOrIpod() || detectAndroidPhone() || detectWindowsPhone() || detectBlackBerry10Phone() || (detectBlackBerryWebKit() && detectBlackBerryTouch()) || detectPalmWebOS() || detectBada() || detectTizen() || detectFirefoxOSPhone() || detectSailfishPhone() || detectUbuntuPhone() || detectGamingHandheld()) { return true; } return false; }
java
{ "resource": "" }
q1692
UAgentInfo.detectTierRichCss
train
public boolean detectTierRichCss() { boolean result = false; //The following devices are explicitly ok. //Note: 'High' BlackBerry devices ONLY if (detectMobileQuick()) { //Exclude iPhone Tier and e-Ink Kindle devices. if (!detectTierIphone() && !detectKindle()) { //The following devices are explicitly ok. //Note: 'High' BlackBerry devices ONLY //Older Windows 'Mobile' isn't good enough for iPhone Tier. if (detectWebkit() || detectS60OssBrowser() || detectBlackBerryHigh() || detectWindowsMobile() || (userAgent.indexOf(engineTelecaQ) != -1)) { result = true; } // if detectWebkit() } //if !detectTierIphone() } //if detectMobileQuick() return result; }
java
{ "resource": "" }
q1693
CmsSerialDateBeanMonthly.setCorrectDay
train
private void setCorrectDay(Calendar date) { if (monthHasNotDay(date)) { date.set(Calendar.DAY_OF_MONTH, date.getActualMaximum(Calendar.DAY_OF_MONTH)); } else { date.set(Calendar.DAY_OF_MONTH, m_dayOfMonth); } }
java
{ "resource": "" }
q1694
CmsSetupBean.getDbProperty
train
public String getDbProperty(String key) { // extract the database key out of the entire key String databaseKey = key.substring(0, key.indexOf('.')); Properties databaseProperties = getDatabaseProperties().get(databaseKey); return databaseProperties.getProperty(key, ""); }
java
{ "resource": "" }
q1695
CmsSetupBean.isChecked
train
public String isChecked(String value1, String value2) { if ((value1 == null) || (value2 == null)) { return ""; } if (value1.trim().equalsIgnoreCase(value2.trim())) { return "checked"; } return ""; }
java
{ "resource": "" }
q1696
CmsLoginManager.canLockBecauseOfInactivity
train
public boolean canLockBecauseOfInactivity(CmsObject cms, CmsUser user) { return !user.isManaged() && !user.isWebuser() && !OpenCms.getDefaultUsers().isDefaultUser(user.getName()) && !OpenCms.getRoleManager().hasRole(cms, user.getName(), CmsRole.ROOT_ADMIN); }
java
{ "resource": "" }
q1697
CmsLogFileApp.addDownloadButton
train
private void addDownloadButton(final CmsLogFileView view) { Button button = CmsToolBar.createButton( FontOpenCms.DOWNLOAD, CmsVaadinUtils.getMessageText(Messages.GUI_LOGFILE_DOWNLOAD_0)); button.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { Window window = CmsBasicDialog.prepareWindow(CmsBasicDialog.DialogWidth.wide); window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_LOGFILE_DOWNLOAD_0)); window.setContent(new CmsLogDownloadDialog(window, view.getCurrentFile())); A_CmsUI.get().addWindow(window); } }); m_uiContext.addToolbarButton(button); }
java
{ "resource": "" }
q1698
CmsCmisUtil.addPropertyDefault
train
@SuppressWarnings("unchecked") public static boolean addPropertyDefault(PropertiesImpl props, PropertyDefinition<?> propDef) { if ((props == null) || (props.getProperties() == null)) { throw new IllegalArgumentException("Props must not be null!"); } if (propDef == null) { return false; } List<?> defaultValue = propDef.getDefaultValue(); if ((defaultValue != null) && (!defaultValue.isEmpty())) { switch (propDef.getPropertyType()) { case BOOLEAN: props.addProperty(new PropertyBooleanImpl(propDef.getId(), (List<Boolean>)defaultValue)); break; case DATETIME: props.addProperty(new PropertyDateTimeImpl(propDef.getId(), (List<GregorianCalendar>)defaultValue)); break; case DECIMAL: props.addProperty(new PropertyDecimalImpl(propDef.getId(), (List<BigDecimal>)defaultValue)); break; case HTML: props.addProperty(new PropertyHtmlImpl(propDef.getId(), (List<String>)defaultValue)); break; case ID: props.addProperty(new PropertyIdImpl(propDef.getId(), (List<String>)defaultValue)); break; case INTEGER: props.addProperty(new PropertyIntegerImpl(propDef.getId(), (List<BigInteger>)defaultValue)); break; case STRING: props.addProperty(new PropertyStringImpl(propDef.getId(), (List<String>)defaultValue)); break; case URI: props.addProperty(new PropertyUriImpl(propDef.getId(), (List<String>)defaultValue)); break; default: throw new RuntimeException("Unknown datatype! Spec change?"); } return true; } return false; }
java
{ "resource": "" }
q1699
CmsCmisUtil.checkAddProperty
train
public static boolean checkAddProperty( CmsCmisTypeManager typeManager, Properties properties, String typeId, Set<String> filter, String id) { if ((properties == null) || (properties.getProperties() == null)) { throw new IllegalArgumentException("Properties must not be null!"); } if (id == null) { throw new IllegalArgumentException("Id must not be null!"); } TypeDefinition type = typeManager.getType(typeId); if (type == null) { throw new IllegalArgumentException("Unknown type: " + typeId); } if (!type.getPropertyDefinitions().containsKey(id)) { throw new IllegalArgumentException("Unknown property: " + id); } String queryName = type.getPropertyDefinitions().get(id).getQueryName(); if ((queryName != null) && (filter != null)) { if (!filter.contains(queryName)) { return false; } else { filter.remove(queryName); } } return true; }
java
{ "resource": "" }