method2testcases stringlengths 118 3.08k |
|---|
### Question:
ShadowResources { @NonNull public int[] getIntArray(@ArrayRes int id) throws NotFoundException { Map<Integer, String> idNameMap = getArrayIdTable(); Map<String, List<Integer>> intArrayMap = getResourceIntArrayMap(); if (idNameMap.containsKey(id)) { String name = idNameMap.get(id); if (intArrayMap.contains... |
### Question:
ShadowResources { public String getPackageName() { if (!TextUtils.isEmpty(mPackageName)) { return mPackageName; } String manifestPath = "build/intermediates/bundles/debug/AndroidManifest.xml"; if (!new File(manifestPath).exists()) { manifestPath = "build/intermediates/bundles/release/AndroidManifest.xml";... |
### Question:
KbSqlParserManager { public Statement parse(String sql) throws JSQLParserException { sql = sql.trim(); boolean isInsertOrReplace = false; if (sql.toUpperCase().startsWith("INSERT OR REPLACE")) { isInsertOrReplace = true; String[] sqlParts = new String[2]; sqlParts[0] = sql.substring(0, "INSERT OR REPLACE"... |
### Question:
KbSqlParser { protected static int getBindArgsCount(String sql) { Set<Expression> expressionSet = findBindArgsExpressions(sql); int count = 0; for (Expression expression : expressionSet) { count += getBindArgsCount(expression); } return count; } static String bindArgs(String sql, @Nullable Object[] bindA... |
### Question:
KbSqlParser { protected static Set<Expression> findBindArgsExpressions(String sql) { if (sql == null || sql.startsWith("PRAGMA") || !sql.contains("?")) { return new LinkedHashSet<>(); } KbSqlParserManager pm = new KbSqlParserManager(); try { Statement statement = pm.parse(sql); Set<Expression> expressionS... |
### Question:
ShadowContext implements Shadow { public static void deleteAllTempDir() { FileUtils.deletePath(DB_PATH); FileUtils.deletePath(DATA_DIR); FileUtils.deletePath(EXT_DIR); } ShadowContext(Resources resources); @NonNull final String getString(@StringRes int resId); Resources getResources(); SharedPreferences g... |
### Question:
NoOpWorkflowImpl implements NoOpWorkflow { @Override public void run() { System.out.println("Run called"); run(0); } @Override void run(); }### Answer:
@Test public void testRun() { context.checking( new Expectations() { { exactly(3).of(control).createDatabaseName("test"); will(returnValue("bbb")); } })... |
### Question:
UriBuilderImpl extends UriBuilder { @Override public UriBuilder replaceQueryParam(String name, Object... values) { checkSsp(); if (queryParams == null) { queryParams = UriComponent.decodeQuery(query.toString(), false); query.setLength(0); } name = encode(name, UriComponent.Type.QUERY_PARAM); queryParams.r... |
### Question:
DemoAO { public void hello(String name) throws FileNotFoundException { System.out.println(demoService.sayHello(name)); } void hello(String name); }### Answer:
@Test public void testHello() throws FileNotFoundException { demoAO.hello("抠逼阵儿"); } |
### Question:
ClipboardModule extends ContextBaseJavaModule { @SuppressLint("DeprecatedMethod") @ReactMethod public void setString(String text) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ClipData clipdata = ClipData.newPlainText(null, text); ClipboardManager clipboard = getClipboardService(); clipb... |
### Question:
PdfParser { static List<String> extractTextLinesFromPdf(InputStream pdfStream) { PdfReader pdfReader = null; try { pdfReader = new PdfReader(pdfStream); List<String> textLines = new ArrayList<>(); for (int page = 1; page <= pdfReader.getNumberOfPages(); page++) { String textFromPage = PdfTextExtractor.get... |
### Question:
PdfParser { static String parseLabel(List<String> variableSection) { List<String> fieldText = extractFieldContent(variableSection, FIELD_NAME_LABEL, FIELD_NAME_LABEL_ALT1); List<String> fieldParagraphs = extractParagraphs(fieldText); if (fieldParagraphs.size() != 1) throw new IllegalStateException( String... |
### Question:
DatabaseSchemaManager { public static void createOrUpdateSchema(DataSource dataSource) { LOGGER.info("Schema create/upgrade: running..."); Flyway flyway = new Flyway(); flyway.setCleanDisabled(true); flyway.setDataSource(dataSource); flyway.setPlaceholders(createScriptPlaceholdersMap(dataSource)); flyway.... |
### Question:
CommandContext { public boolean hasFlag(char ch) { return booleanFlags.contains(ch) || valueFlags.containsKey(ch); } CommandContext(String args); CommandContext(String[] args); CommandContext(String args, Set<Character> valueFlags); CommandContext(String args, Set<Character> valueFlags, boolean allowHa... |
### Question:
Location { public Location setY(double y) { return new Location(extent, position.withY(y), yaw, pitch); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); ... |
### Question:
Location { public double getZ() { return position.getZ(); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, double x, double y, d... |
### Question:
Location { public int getBlockZ() { return (int) Math.floor(position.getZ()); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, d... |
### Question:
Location { public Location setZ(double z) { return new Location(extent, position.withZ(z), yaw, pitch); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); ... |
### Question:
MorePaths { public static Stream<Path> iterPaths(Path path) { Deque<Path> parents = new ArrayDeque<>(path.getNameCount()); Path next = path; while (next != null) { parents.addFirst(next); next = next.getParent(); } return ImmutableList.copyOf(parents).stream(); } private MorePaths(); static Comparator<Pa... |
### Question:
EventBus { public void register(Object object) { subscribeAll(finder.findAllSubscribers(object)); } void subscribe(Class<?> clazz, EventHandler handler); void subscribeAll(Multimap<Class<?>, EventHandler> handlers); void unsubscribe(Class<?> clazz, EventHandler handler); void unsubscribeAll(Multimap<Clas... |
### Question:
EventBus { public void unregister(Object object) { unsubscribeAll(finder.findAllSubscribers(object)); } void subscribe(Class<?> clazz, EventHandler handler); void subscribeAll(Multimap<Class<?>, EventHandler> handlers); void unsubscribe(Class<?> clazz, EventHandler handler); void unsubscribeAll(Multimap<... |
### Question:
CommandContext { public String[] getSlice(int index) { String[] slice = new String[originalArgs.length - index]; System.arraycopy(originalArgs, index, slice, 0, originalArgs.length - index); return slice; } CommandContext(String args); CommandContext(String[] args); CommandContext(String args, Set<Chara... |
### Question:
Expression { public double evaluate(double... values) throws EvaluationException { return evaluate(values, WorldEdit.getInstance().getConfiguration().calculationTimeout); } private Expression(String expression, String... variableNames); static Expression compile(String expression, String... variableNames... |
### Question:
Expression { public static Expression compile(String expression, String... variableNames) throws ExpressionException { return new Expression(expression, variableNames); } private Expression(String expression, String... variableNames); static Expression compile(String expression, String... variableNames);... |
### Question:
FileSystemSnapshotDatabase implements SnapshotDatabase { public Path getRoot() { return root; } FileSystemSnapshotDatabase(Path root, ArchiveNioSupport archiveNioSupport); static ZonedDateTime tryParseDate(Path path); static URI createUri(String name); static FileSystemSnapshotDatabase maybeCreate(
... |
### Question:
DinnerPermsResolver implements PermissionsResolver { @Override @SuppressWarnings("deprecation") public boolean inGroup(String name, String group) { return inGroup(server.getOfflinePlayer(name), group); } DinnerPermsResolver(Server server); static PermissionsResolver factory(Server server, YAMLProcessor co... |
### Question:
CommandContext { public int argsLength() { return parsedArgs.size(); } CommandContext(String args); CommandContext(String[] args); CommandContext(String args, Set<Character> valueFlags); CommandContext(String args, Set<Character> valueFlags, boolean allowHangingFlag); CommandContext(String[] args, Set... |
### Question:
Location { public Extent getExtent() { return extent; } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, double x, double y, doubl... |
### Question:
Location { public Vector3 toVector() { return position; } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, double x, double y, dou... |
### Question:
Location { public double getX() { return position.getX(); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, double x, double y, d... |
### Question:
Location { public int getBlockX() { return (int) Math.floor(position.getX()); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, d... |
### Question:
Location { public Location setX(double x) { return new Location(extent, position.withX(x), yaw, pitch); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); ... |
### Question:
Location { public double getY() { return position.getY(); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, double x, double y, d... |
### Question:
Location { public int getBlockY() { return (int) Math.floor(position.getY()); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, d... |
### Question:
ViewerResourceBundle extends ResourceBundle { static String replaceParameters(final String msg, String... params) { String ret = msg; if (ret != null && params != null) { for (int i = 0; i < params.length; ++i) { ret = ret.replace(new StringBuilder("{").append(i).append("}").toString(), params[i]); } } re... |
### Question:
LeanPageLoader extends AbstractPageLoader implements Serializable { @Override public int getNumPages() throws IndexUnreachableException { if (numPages < 0) { numPages = topElement.getNumPages(); } return numPages; } LeanPageLoader(StructElement topElement, int numPages); @Override int getNumPages(); @Over... |
### Question:
LeanPageLoader extends AbstractPageLoader implements Serializable { @Override public PhysicalElement getPageForFileName(String fileName) throws PresentationException, IndexUnreachableException, DAOException { return loadPage(-1, fileName); } LeanPageLoader(StructElement topElement, int numPages); @Overrid... |
### Question:
EagerPageLoader extends AbstractPageLoader implements Serializable { @Override public int getNumPages() { return pages.size(); } EagerPageLoader(StructElement topElement); @Override int getNumPages(); @Override int getFirstPageOrder(); @Override int getLastPageOrder(); @Override PhysicalElement getPage(in... |
### Question:
EagerPageLoader extends AbstractPageLoader implements Serializable { @Override public PhysicalElement getPage(int pageOrder) { return pages.get(pageOrder); } EagerPageLoader(StructElement topElement); @Override int getNumPages(); @Override int getFirstPageOrder(); @Override int getLastPageOrder(); @Overri... |
### Question:
EagerPageLoader extends AbstractPageLoader implements Serializable { @Override public PhysicalElement getPageForFileName(String fileName) { for (int key : pages.keySet()) { PhysicalElement page = pages.get(key); if (fileName.equals(page.getFileName())) { return page; } } return null; } EagerPageLoader(Str... |
### Question:
EagerPageLoader extends AbstractPageLoader implements Serializable { @Override public int getFirstPageOrder() { return firstPageOrder; } EagerPageLoader(StructElement topElement); @Override int getNumPages(); @Override int getFirstPageOrder(); @Override int getLastPageOrder(); @Override PhysicalElement ge... |
### Question:
EagerPageLoader extends AbstractPageLoader implements Serializable { @Override public int getLastPageOrder() { return lastPageOrder; } EagerPageLoader(StructElement topElement); @Override int getNumPages(); @Override int getFirstPageOrder(); @Override int getLastPageOrder(); @Override PhysicalElement getP... |
### Question:
AbstractPageLoader implements IPageLoader { protected String buildPageLabelTemplate(String format, Locale locale) throws IndexUnreachableException { if (format == null) { throw new IllegalArgumentException("format may not be null"); } String labelTemplate = format.replace("{numpages}", String.valueOf(getN... |
### Question:
EventElement implements Comparable<EventElement>, Serializable { public Date getDateStart() { return dateStart; } EventElement(SolrDocument doc, Locale locale); @Override int compareTo(EventElement o); String getDisplayDate(); String getLabel(); String getType(); void setType(String type); Date getDateSta... |
### Question:
EventElement implements Comparable<EventElement>, Serializable { public Date getDateEnd() { return dateEnd; } EventElement(SolrDocument doc, Locale locale); @Override int compareTo(EventElement o); String getDisplayDate(); String getLabel(); String getType(); void setType(String type); Date getDateStart()... |
### Question:
TocMaker { protected static List<String> getSolrFieldsToFetch(String template) { logger.trace("getSolrFieldsToFetch: {}", template); Set<String> ret = new HashSet<>(Arrays.asList(REQUIRED_FIELDS)); List<Metadata> metadataList = DataManager.getInstance().getConfiguration().getTocLabelConfiguration(template... |
### Question:
CalendarView { public List<String> getVolumeYears() throws PresentationException, IndexUnreachableException { if (anchorPi == null) { return Collections.emptyList(); } return SearchHelper.getFacetValues("+" + SolrConstants.PI_ANCHOR + ":" + anchorPi + " +" + SolrConstants._CALENDAR_DAY + ":*", SolrConstan... |
### Question:
Sitemap { private Element createUrlElement(String pi, int order, String dateModified, String type, String changefreq, String priority) { return createUrlElement(viewerRootUrl + '/' + type + '/' + pi + '/' + order + '/', dateModified, changefreq, priority); } List<File> generate(String viewerRootUrl, Stri... |
### Question:
ViewerPathBuilder { public static boolean startsWith(URI uri, String string) { if (uri != null) { if (uri.toString().endsWith("/") && !string.endsWith("/")) { string = string + "/"; } String[] uriParts = uri.toString().split("/"); String[] stringParts = string.toString().split("/"); if (uriParts.length < ... |
### Question:
AdvancedSearchFieldConfiguration { public String getLabel() { if (label == null) { return field; } return label; } AdvancedSearchFieldConfiguration(String field); String getField(); String getLabel(); AdvancedSearchFieldConfiguration setLabel(String label); boolean isHierarchical(); AdvancedSearchFieldCon... |
### Question:
UserTools { public static int deleteBookmarkListsForUser(User owner) throws DAOException { List<BookmarkList> bookmarkLists = DataManager.getInstance().getDao().getBookmarkLists(owner); if (bookmarkLists.isEmpty()) { return 0; } int count = 0; for (BookmarkList bookmarkList : bookmarkLists) { if (DataMana... |
### Question:
UserTools { public static int deleteSearchesForUser(User owner) throws DAOException { List<Search> searches = DataManager.getInstance().getDao().getSearches(owner); if (searches.isEmpty()) { return 0; } int count = 0; for (Search search : searches) { if (DataManager.getInstance().getDao().deleteSearch(sea... |
### Question:
UserTools { public static int deleteUserGroupOwnedByUser(User owner) throws DAOException { List<UserGroup> userGroups = owner.getUserGroupOwnerships(); if (userGroups.isEmpty()) { return 0; } int count = 0; for (UserGroup userGroup : userGroups) { if (!userGroup.getMemberships().isEmpty()) { for (UserRole... |
### Question:
UserTools { public static void deleteUserPublicContributions(User user) throws DAOException { if (user == null) { return; } int comments = DataManager.getInstance().getDao().deleteComments(null, user); logger.debug("{} comment(s) of user {} deleted.", comments, user.getId()); int statistics = DataManager.... |
### Question:
UserTools { public static boolean anonymizeUserPublicContributions(User user) throws DAOException { User anon = UserTools.checkAndCreateAnonymousUser(); if (anon == null) { logger.error("Anonymous user could not be found"); return false; } int comments = DataManager.getInstance().getDao().changeCommentsOw... |
### Question:
UserGroup implements ILicensee, Serializable { public long getMemberCount() throws DAOException { return DataManager.getInstance().getDao().getUserRoleCount(this, null, null); } @Override int hashCode(); @Override boolean equals(Object obj); boolean addMember(User user, Role role); boolean changeMemberRo... |
### Question:
UserGroup implements ILicensee, Serializable { public Set<User> getMembersAndOwner() throws DAOException { Set<User> ret = new HashSet<>(getMembers()); ret.add(getOwner()); return ret; } @Override int hashCode(); @Override boolean equals(Object obj); boolean addMember(User user, Role role); boolean chang... |
### Question:
BibliothecaAuthenticationRequest extends UserPasswordAuthenticationRequest { static String normalizeUsername(String username) { if (username == null || username.length() == 11) { return username; } if (username.length() < 11) { StringBuilder sb = new StringBuilder(11); for (int i = username.length(); i < ... |
### Question:
BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { public static String normalizeString(String s, String ignoreChars) { if (s == null) { return null; } if (StringUtils.isNotEmpty(ignoreChars)) { while (s.length() > 1 && ignoreChars.contains(s.substring(0, 1))) { s = s.substring(1); } }... |
### Question:
LitteraProvider extends HttpAuthenticationProvider { @Override public CompletableFuture<LoginResult> login(String loginName, String password) throws AuthenticationProviderException { try { LitteraAuthenticationResponse response = get(new URI(getUrl()), loginName, password); Optional<User> user = getUser(l... |
### Question:
SitelinkBean implements Serializable { public List<String> getAvailableValuesForField(String field, String filterQuery) throws PresentationException, IndexUnreachableException { if (field == null) { throw new IllegalArgumentException("field may not be null"); } if (filterQuery == null) { throw new Illegal... |
### Question:
CmsMediaBean implements Serializable { public List<CMSCategory> getAllMediaCategories() throws DAOException { return DataManager.getInstance().getDao().getAllCategories(); } CmsMediaBean(); void resetData(); CMSMediaItem createMediaItem(); List<CMSPage> getMediaOwnerPages(CMSMediaItem item); void deleteMe... |
### Question:
MediaHandler { public String getMediaUrl(String type, String format, String pi, String filename) throws IllegalRequestException { if(urls != null) { if(type.equalsIgnoreCase("audio")) { return urls.path(ApiUrls.RECORDS_FILES, ApiUrls.RECORDS_FILES_AUDIO).params(pi, format, filename).build(); } else if(typ... |
### Question:
PdfHandler { public String getPdfUrl(StructElement doc, PhysicalElement page) { return getPdfUrl(doc, new PhysicalElement[] { page }); } PdfHandler(WatermarkHandler watermarkHandler, Configuration configuration); PdfHandler(WatermarkHandler watermarkHandler, AbstractApiUrlManager urls); String getPdfUrl(... |
### Question:
IIIFPresentationAPIHandler { public String getManifestUrl(String pi) throws URISyntaxException { return builder.getManifestURI(pi).toString(); } IIIFPresentationAPIHandler(AbstractApiUrlManager urls, Configuration configuration); String getManifestUrl(String pi); String getCollectionUrl(); String getColle... |
### Question:
IIIFPresentationAPIHandler { public String getCollectionUrl() throws URISyntaxException { return getCollectionUrl(SolrConstants.DC); } IIIFPresentationAPIHandler(AbstractApiUrlManager urls, Configuration configuration); String getManifestUrl(String pi); String getCollectionUrl(); String getCollectionUrl(S... |
### Question:
IIIFPresentationAPIHandler { public String getLayerUrl(String pi, String annotationType) throws URISyntaxException { AnnotationType type = AnnotationType.valueOf(annotationType.toUpperCase()); if (type == null) { throw new IllegalArgumentException(annotationType + " is not valid annotation type"); } retur... |
### Question:
IIIFPresentationAPIHandler { public String getAnnotationsUrl(String pi, int pageOrder, String annotationType) throws URISyntaxException { AnnotationType type = AnnotationType.valueOf(annotationType.toUpperCase()); if (type == null) { throw new IllegalArgumentException(annotationType + " is not valid annot... |
### Question:
IIIFPresentationAPIHandler { public String getCanvasUrl(String pi, int pageOrder) throws URISyntaxException { return builder.getCanvasURI(pi, pageOrder).toString(); } IIIFPresentationAPIHandler(AbstractApiUrlManager urls, Configuration configuration); String getManifestUrl(String pi); String getCollection... |
### Question:
IIIFPresentationAPIHandler { public String getRangeUrl(String pi, String logId) throws URISyntaxException { return builder.getRangeURI(pi, logId).toString(); } IIIFPresentationAPIHandler(AbstractApiUrlManager urls, Configuration configuration); String getManifestUrl(String pi); String getCollectionUrl(); ... |
### Question:
XmlTools { public static Document getDocumentFromString(String string, String encoding) throws JDOMException, IOException { if (encoding == null) { encoding = StringTools.DEFAULT_ENCODING; } byte[] byteArray = null; try { byteArray = string.getBytes(encoding); } catch (UnsupportedEncodingException e) { } ... |
### Question:
XmlTools { public static String getStringFromElement(Object element, String encoding) { if (element == null) { throw new IllegalArgumentException("element may not be null"); } if (encoding == null) { encoding = StringTools.DEFAULT_ENCODING; } Format format = Format.getRawFormat(); XMLOutputter outputter =... |
### Question:
XmlTools { public static File writeXmlFile(Document doc, String filePath) throws FileNotFoundException, IOException { return FileTools.getFileFromString(getStringFromElement(doc, StringTools.DEFAULT_ENCODING), filePath, StringTools.DEFAULT_ENCODING, false); } static Document readXmlFile(String filePath);... |
### Question:
XmlTools { public static Document readXmlFile(String filePath) throws FileNotFoundException, IOException, JDOMException { try (FileInputStream fis = new FileInputStream(new File(filePath))) { return new SAXBuilder().build(fis); } } static Document readXmlFile(String filePath); static Document readXmlFile... |
### Question:
ViewerResourceBundle extends ResourceBundle { public static List<Locale> getLocalesFromFile(Path facesConfigPath) throws FileNotFoundException, IOException, JDOMException { Document doc = XmlTools.readXmlFile(facesConfigPath); Namespace xsi = Namespace.getNamespace("xsi", "http: Namespace javaee = Namespa... |
### Question:
SecurityQuestion { public boolean isAnswerCorrect(String answer) { answered = true; if (StringUtils.isBlank(answer)) { return false; } return correctAnswers.contains(answer.toLowerCase()); } SecurityQuestion(String questionKey, Set<String> correctAnswers); boolean isAnswerCorrect(String answer); String ge... |
### Question:
DCRecordWriter { public void write(Path path) throws IOException { Path filePath = path; if(Files.isDirectory(path)) { if(StringUtils.isNotBlank(getMetadataValue("identifier"))) { filePath = path.resolve(getMetadataValue("identifier") + ".xml"); } else if(StringUtils.isNotBlank(getMetadataValue("title")))... |
### Question:
RecordLock { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; RecordLock other = (RecordLock) obj; if (pi == null) { if (other.pi != null) return false; } else if (!pi.equals(other.pi)) return false; ... |
### Question:
RecordLockManager { public synchronized void lockRecord(String pi, String sessionId, Integer limit) throws RecordLimitExceededException { logger.trace("lockRecord: {}", pi); if (pi == null) { throw new IllegalArgumentException("pi may not be null"); } if (sessionId == null) { logger.warn("No sessionId giv... |
### Question:
MetadataTools { public static String findMetadataGroupType(String gndspec) { if (gndspec == null) { return null; } if (gndspec.length() == 3) { String ret = null; switch (gndspec.substring(0, 2)) { case "gi": ret = MetadataGroupType.LOCATION.name(); break; case "ki": ret = MetadataGroupType.CORPORATION.na... |
### Question:
MetadataTools { public static String convertLanguageToIso2(String language) { if (language == null) { return null; } if (language.length() == 3) { Language lang = null; try { lang = DataManager.getInstance().getLanguageHelper().getLanguage(language); } catch (IllegalArgumentException e) { logger.warn("No ... |
### Question:
Comment implements Comparable<Comment> { public boolean mayEdit(User user) { return owner.getId() != null && user != null && owner.getId() == user.getId(); } Comment(); Comment(String pi, int page, User owner, String text, Comment parent); @Override int compareTo(Comment o); static boolean sendEmailNotif... |
### Question:
TEITools { public static String getTeiFulltext(String tei) throws JDOMException, IOException { if (tei == null) { return null; } Document doc = XmlTools.getDocumentFromString(tei, StringTools.DEFAULT_ENCODING); if (doc == null) { return null; } if (doc.getRootElement() != null) { Element eleText = doc.get... |
### Question:
ALTOTools { public static String getFulltext(Path path, String encoding) throws IOException { String altoString = FileTools.getStringFromFile(path.toFile(), encoding); return getFullText(altoString, false, null); } static String getFulltext(Path path, String encoding); static String getFullText(String al... |
### Question:
CMSSidebarElement { protected static String cleanupHtmlTag(String tag) { Matcher m2 = patternHtmlAttribute.matcher(tag); while (m2.find()) { String attribute = m2.group(); tag = tag.replace(attribute, ""); } tag = tag.replace("</", "<").replace("/>", ">").replace(" ", ""); return tag; } CMSSidebarElement(... |
### Question:
FileTools { public static String getStringFromFile(File file, String encoding) throws FileNotFoundException, IOException { return getStringFromFile(file, encoding, null); } static String getStringFromFilePath(String filePath); static String getStringFromFile(File file, String encoding); static String get... |
### Question:
FileTools { public static String getStringFromFilePath(String filePath) throws FileNotFoundException, IOException { return getStringFromFile(new File(filePath), null); } static String getStringFromFilePath(String filePath); static String getStringFromFile(File file, String encoding); static String getStr... |
### Question:
FileTools { public static void compressGzipFile(File file, File gzipFile) throws FileNotFoundException, IOException { try (FileInputStream fis = new FileInputStream(file); FileOutputStream fos = new FileOutputStream(gzipFile); GZIPOutputStream gzipOS = new GZIPOutputStream(fos)) { byte[] buffer = new byte... |
### Question:
FileTools { public static void decompressGzipFile(File gzipFile, File newFile) throws FileNotFoundException, IOException { try (FileInputStream fis = new FileInputStream(gzipFile); GZIPInputStream gis = new GZIPInputStream(fis); FileOutputStream fos = new FileOutputStream(newFile)) { byte[] buffer = new b... |
### Question:
FileTools { public static File getFileFromString(String string, String filePath, String encoding, boolean append) throws IOException { if (string == null) { throw new IllegalArgumentException("string may not be null"); } if (encoding == null) { encoding = StringTools.DEFAULT_ENCODING; } File file = new Fi... |
### Question:
FileTools { public static String getCharset(InputStream input) throws IOException { CharsetDetector cd = new CharsetDetector(); try (BufferedInputStream bis = new BufferedInputStream(input)) { cd.setText(bis); CharsetMatch cm = cd.detect(); if (cm != null) { return cm.getName(); } } return null; } static... |
### Question:
FileTools { public static String getBottomFolderFromPathString(String pathString) { if (StringUtils.isBlank(pathString)) { return ""; } Path path = Paths.get(pathString); return path.getParent() != null ? path.getParent().getFileName().toString() : ""; } static String getStringFromFilePath(String filePat... |
### Question:
FileTools { public static String getFilenameFromPathString(String pathString) { if (StringUtils.isBlank(pathString)) { return ""; } Path path = getPathFromUrlString(pathString); return path.getFileName().toString(); } static String getStringFromFilePath(String filePath); static String getStringFromFile(F... |
### Question:
LanguageHelper { public Language getLanguage(String isoCode) { SubnodeConfiguration languageConfig = null; try { if (isoCode.length() == 3) { List<HierarchicalConfiguration> nodes = config.configurationsAt("language[iso_639-2=\"" + isoCode + "\"]"); if (nodes.isEmpty()) { nodes = config.configurationsAt("... |
### Question:
DataFileTools { static String getDataRepositoryPath(String dataRepositoryPath) { if (StringUtils.isBlank(dataRepositoryPath)) { return DataManager.getInstance().getConfiguration().getViewerHome(); } if (Paths.get(FileTools.adaptPathForWindows(dataRepositoryPath)).isAbsolute()) { return dataRepositoryPath ... |
### Question:
DataFileTools { static String sanitizeFileName(String fileName) { if (StringUtils.isBlank(fileName)) { return fileName; } return Paths.get(fileName).getFileName().toString(); } static String getDataRepositoryPathForRecord(String pi); static Path getMediaFolder(String pi); static Map<String, Path> getData... |
### Question:
CMSStaticPage { public String getPageName() { return pageName; } CMSStaticPage(); CMSStaticPage(String name); @SuppressWarnings("deprecation") CMSStaticPage(CMSPage cmsPage); Optional<CMSPage> getCmsPageOptional(); CMSPage getCmsPage(); void setCmsPage(CMSPage cmsPage); Long getId(); String getPageName(... |
### Question:
NetTools { protected static String parseMultipleIpAddresses(String address) { if (address == null) { throw new IllegalArgumentException("address may not be null"); } if (address.contains(",")) { String[] addressSplit = address.split(","); if (addressSplit.length > 0) { address = addressSplit[addressSplit.... |
### Question:
NetTools { public static String scrambleEmailAddress(String email) { if (StringUtils.isEmpty(email)) { return email; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < email.length(); ++i) { if (i > 2 && i < email.length() - 3) { sb.append('*'); } else { sb.append(email.charAt(i)); } } return s... |
### Question:
NetTools { public static String scrambleIpAddress(String address) { if (StringUtils.isEmpty(address)) { return address; } String[] addressSplit = address.split("[.]"); if (addressSplit.length == 4) { return addressSplit[0] + "." + addressSplit[1] + ".X.X"; } return address; } static String[] callUrlGET(S... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.