_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q163300 | WaybackRequest.createCaptureQueryRequet | train | public static WaybackRequest createCaptureQueryRequet(String url, String replay, String start, String end) {
WaybackRequest r = new WaybackRequest();
r.setCaptureQueryRequest();
r.setRequestUrl(url);
r.setReplayTimestamp(replay);
r.setStartTimestamp(start);
r.setEndTimestamp(end);
return r;
} | java | {
"resource": ""
} |
q163301 | WaybackRequest.createReplayRequest | train | public static WaybackRequest createReplayRequest(String url, String replay, String start, String end) {
WaybackRequest r = new WaybackRequest();
r.setReplayRequest();
r.setRequestUrl(url);
r.setReplayTimestamp(replay);
r.setStartTimestamp(start);
r.setEndTimestamp(end);
return r;
} | java | {
"resource": ""
} |
q163302 | WaybackRequest.setRequestUrl | train | public void setRequestUrl(String urlStr) {
// This looks a little confusing: We're trying to fixup an incoming
// request URL that starts with:
// "http(s):/www.archive.org"
// so it becomes:
// "http(s)://www.archive.org"
// (note the missing second "/" in the first)
//
// if that is not... | java | {
"resource": ""
} |
q163303 | WaybackRequest.extractHttpRequestInfo | train | public void extractHttpRequestInfo(HttpServletRequest httpRequest) {
putUnlessNull(REQUEST_REFERER_URL, httpRequest.getHeader("REFERER"));
String remoteAddr = httpRequest.getHeader("X-Forwarded-For");
remoteAddr = (remoteAddr == null) ?
httpRequest.getRemoteAddr() :
remoteAddr + ", " + httpRequest.ge... | java | {
"resource": ""
} |
q163304 | PortMapper.addRequestHandler | train | public void addRequestHandler(String host, String firstPath,
RequestHandler requestHandler) {
String key = hostPathToKey(host, firstPath);
if (pathMap.containsKey(key)) {
LOGGER.warning("Duplicate port:path map for " + port +
":" + key);
} else {
pathMap.put(key, requestHandler);
if (LOGGER.isLo... | java | {
"resource": ""
} |
q163305 | IndexQueueUpdater.updateQueue | train | public int updateQueue() throws IOException {
int added = 0;
long lastMarkPoint = lastMark.getLastMark();
long currentMarkPoint = db.getCurrentMark();
if(currentMarkPoint > lastMarkPoint) {
// TODO: touchy touchy... need transactions here to not have
// state sync problems if something goes badly in this... | java | {
"resource": ""
} |
q163306 | BDBMap.getTimestampForId | train | public static String getTimestampForId(String context, String ip) {
BDBMap bdbMap = getContextMap(context);
String dateStr = bdbMap.get(ip);
return (dateStr != null) ? dateStr : Timestamp.currentTimestamp().getDateStr();
} | java | {
"resource": ""
} |
q163307 | BDBMap.addTimestampForId | train | public static void addTimestampForId(String context, String ip, String time) {
BDBMap bdbMap = getContextMap(context);
bdbMap.put(ip, time);
} | java | {
"resource": ""
} |
q163308 | SelectorReplayDispatcher.shouldDetectMimeType | train | protected boolean shouldDetectMimeType(String mimeType) {
for (String prefix : untrustfulMimeTypes) {
if (mimeType.startsWith(prefix)) return true;
}
return false;
} | java | {
"resource": ""
} |
q163309 | NutchResourceIndex.getNodeContent | train | protected String getNodeContent(Element e, String key) {
NodeList nodes = e.getElementsByTagName(key);
String result = null;
if (nodes != null && nodes.getLength() > 0) {
result = getNodeTextValue(nodes.item(0));
}
return (result == null || result.length() == 0)? null: resu... | java | {
"resource": ""
} |
q163310 | BDBResourceFileLocationDB.nameToUrls | train | public String[] nameToUrls(final String name) throws IOException {
String[] urls = null;
String valueString = get(name);
if(valueString != null && valueString.length() > 0) {
urls = valueString.split(urlDelimiterRE);
}
return urls;
} | java | {
"resource": ""
} |
q163311 | BDBResourceFileLocationDB.addNameUrl | train | public void addNameUrl(final String name, final String url)
throws IOException {
// need to first see if there is already an entry for this name.
// if not, add url as the value.
// if so, check the current url locations for name
// if url exists, do nothing
// if url does not exist, add, and set... | java | {
"resource": ""
} |
q163312 | BDBResourceFileLocationDB.removeNameUrl | train | public void removeNameUrl(final String name, final String url)
throws IOException {
// need to first see if there is already an entry for this name.
// if not, do nothing
// if so, loop thru all current url locations for name
// keep any that are not url
// if any locations are left, update to the new v... | java | {
"resource": ""
} |
q163313 | ArchivalUrl.getDateSpec | train | public static String getDateSpec(WaybackRequest wbRequest, String datespec) {
int dateLen = 0;
if(datespec != null) {
dateLen = datespec.length();
}
StringBuilder sb =
new StringBuilder(dateLen +10);
if(dateLen > 0) {
sb.append(datespec);
}
if(wbRequest.isCSSContext()) {
sb.append(ArchivalUr... | java | {
"resource": ""
} |
q163314 | StaticMapExclusionFilter.setFilterGroup | train | @Override
public void setFilterGroup(ExclusionCaptureFilterGroup filterGroup) {
super.setFilterGroup(filterGroup);
if ((filterGroup != null) && (filterGroup.getCaptureFilterGroupCanonicalizer() != null)) {
this.canonicalizer = filterGroup.getCaptureFilterGroupCanonicalizer();
}
} | java | {
"resource": ""
} |
q163315 | DefaultLiveWebRedirector.handleRedirect | train | @Override
public LiveWebState handleRedirect(WaybackException e, WaybackRequest wbRequest, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException
{
if (statusLiveWebPolicy == null) {
return LiveWebState.NOT_FOUND;
}
// Don't do any redirect for identity context or if no handl... | java | {
"resource": ""
} |
q163316 | ResultsPartition.filter | train | public void filter(CaptureSearchResults results) {
Iterator<CaptureSearchResult> itr = results.iterator();
while(itr.hasNext()) {
CaptureSearchResult result = itr.next();
String captureDate = result.getCaptureTimestamp();
if((captureDate.compareTo(startDateStr) >= 0)
&& (captureDate.compareTo(endDate... | java | {
"resource": ""
} |
q163317 | ByteOp.copy | train | public static byte[] copy(byte[] src, int offset, int length) {
byte[] copy = new byte[length];
System.arraycopy(src, offset, copy, 0, length);
return copy;
} | java | {
"resource": ""
} |
q163318 | ByteOp.cmp | train | public static boolean cmp(byte[] a, byte[] b) {
if(a.length != b.length) {
return false;
}
for(int i = 0; i < a.length; i++) {
if(a[i] != b[i]) {
return false;
}
}
return true;
} | java | {
"resource": ""
} |
q163319 | ByteOp.discardStream | train | public static void discardStream(InputStream is,int size) throws IOException {
byte[] buffer = new byte[size];
while(is.read(buffer, 0, size) != -1) {
}
} | java | {
"resource": ""
} |
q163320 | ByteOp.discardStreamCount | train | public static long discardStreamCount(InputStream is,int size) throws IOException {
long count = 0;
byte[] buffer = new byte[size];
int amt = 0;
while((amt = is.read(buffer, 0, size)) != -1) {
count += amt;
}
return count;
} | java | {
"resource": ""
} |
q163321 | BitArray.set | train | public void set(int i, boolean value) {
int idx = i / 8;
if(idx >= bb.limit()) {
throw new IndexOutOfBoundsException();
}
int bit = 7 - (i % 8);
if(value) {
bb.put(idx, (byte) (bb.get(idx) | MASKS[bit]));
} else {
bb.put(idx,(byte) (bb.get(idx) & MASKSR[bit]));
}
} | java | {
"resource": ""
} |
q163322 | TagMagix.getTagAttr | train | public static String getTagAttr(StringBuilder page, final String tag,
final String attr) {
String found = null;
Pattern daPattern = TagMagix.getPattern(tag, attr);
Matcher matcher = daPattern.matcher(page);
int idx = 0;
if (matcher.find(idx)) {
found = matcher.group(1);
found = trimAttrValue(found)... | java | {
"resource": ""
} |
q163323 | TagMagix.getTagAttrWhere | train | public static String getTagAttrWhere(StringBuilder page, final String tag,
final String findAttr, final String whereAttr, final String whereVal) {
Pattern tagPattern = getWholeTagPattern(tag);
Pattern findAttrPattern = getAttrPattern(findAttr);
Pattern whereAttrPattern = getAttrPattern(whereAttr);
Matcher t... | java | {
"resource": ""
} |
q163324 | UrlOperations.isAuthority | train | public static boolean isAuthority(String authString) {
Matcher m = AUTHORITY_REGEX.matcher(authString);
return (m != null) && m.matches();
} | java | {
"resource": ""
} |
q163325 | UrlOperations.resolveUrl | train | public static String resolveUrl(String baseUrl, String url) {
String resolvedUrl = resolveUrl(baseUrl, url, null);
if (resolvedUrl == null) {
resolvedUrl = url.replace(" ", "%20");
resolvedUrl = resolvedUrl.replace("\r", "%0D");
}
return resolvedUrl;
} | java | {
"resource": ""
} |
q163326 | UrlOperations.resolveUrl | train | public static String resolveUrl(String baseUrl, String url, String defaultValue) {
for(final String scheme : ALL_SCHEMES) {
if(url.startsWith(scheme)) {
try {
return UsableURIFactory.getInstance(url).getEscapedURI();
} catch (URIException e) {
LOGGER.warning(e.getLocalizedMessage() + ": " + ... | java | {
"resource": ""
} |
q163327 | UrlOperations.schemeToDefaultPort | train | public static int schemeToDefaultPort(final String scheme) {
if(scheme.equals(HTTP_SCHEME)) {
return 80;
}
if(scheme.equals(HTTPS_SCHEME)) {
return 443;
}
if(scheme.equals(FTP_SCHEME)) {
return 21;
}
if(scheme.equals(RTSP_SCHEME)) {
return 554;
}
if(scheme.equals(MMS_SCHEME)) {
return 1... | java | {
"resource": ""
} |
q163328 | UrlOperations.stripDefaultPortFromUrl | train | public static String stripDefaultPortFromUrl(String url) {
String scheme = urlToScheme(url);
if(scheme == null) {
return url;
}
int defaultPort = schemeToDefaultPort(scheme);
if(defaultPort == -1) {
return url;
}
String portStr = null;
// is there a slash after the scheme?
int slashIdx = url.in... | java | {
"resource": ""
} |
q163329 | UrlOperations.urlToHost | train | public static String urlToHost(String url) {
String lcUrl = url.toLowerCase();
if(lcUrl.startsWith(DNS_SCHEME)) {
return lcUrl.substring(DNS_SCHEME.length());
}
for(String scheme : ALL_SCHEMES) {
if(lcUrl.startsWith(scheme)) {
int authorityIdx = scheme.length();
Matcher m =
HOST_REGEX_SIMPL... | java | {
"resource": ""
} |
q163330 | UrlOperations.urlToUserInfo | train | public static String urlToUserInfo(String url) {
String lcUrl = url.toLowerCase();
if(lcUrl.startsWith(DNS_SCHEME)) {
return null;
}
for(String scheme : ALL_SCHEMES) {
if(lcUrl.startsWith(scheme)) {
int authorityIdx = scheme.length();
Matcher m =
USERINFO_REGEX_SIMPLE.matcher(lcUrl.substrin... | java | {
"resource": ""
} |
q163331 | UrlOperations.getUrlParentDir | train | public static String getUrlParentDir(String url) {
try {
UsableURI uri = UsableURIFactory.getInstance(url);
String path = uri.getPath();
if(path.length() > 1) {
int startIdx = path.length()-1;
if(path.charAt(path.length()-1) == '/') {
startIdx--;
}
int idx = path.lastIndexOf('/',startIdx... | java | {
"resource": ""
} |
q163332 | AccessPoint.shutdown | train | @Override
public void shutdown() {
if (collection != null) {
try {
collection.shutdown();
} catch (IOException e) {
LOGGER.severe("FAILED collection shutdown" + e.getMessage());
}
}
if (exclusionFactory != null) {
exclusionFactory.shutdown();
}
} | java | {
"resource": ""
} |
q163333 | AccessPoint.setLiveWebPrefix | train | public void setLiveWebPrefix(String liveWebPrefix) {
if (liveWebPrefix == null || liveWebPrefix.isEmpty()) {
this.liveWebRedirector = null;
}
this.liveWebRedirector = new DefaultLiveWebRedirector(liveWebPrefix);
} | java | {
"resource": ""
} |
q163334 | AggressiveUrlCanonicalizer.doStripRegexMatch | train | protected boolean doStripRegexMatch(StringBuilder url, Matcher matcher) {
if(matcher != null && matcher.matches()) {
url.delete(matcher.start(1), matcher.end(1));
return true;
}
return false;
} | java | {
"resource": ""
} |
q163335 | AggressiveUrlCanonicalizer.canonicalize | train | public String canonicalize(String url) {
if (url == null || url.length() <= 0) {
return url;
}
// hang on, we're about to get aggressive:
url = url.toLowerCase();
StringBuilder sb = new StringBuilder(url);
boolean changed = false;
for(int i=0; i<choosers.l... | java | {
"resource": ""
} |
q163336 | CaptureSearchResults.addSearchResult | train | public void addSearchResult(CaptureSearchResult result, boolean append) {
String resultDate = result.getCaptureTimestamp();
if ((firstResultTimestamp == null) ||
(firstResultTimestamp.compareTo(resultDate) > 0)) {
firstResultTimestamp = resultDate;
}
if ((lastResultTimestamp == null) ||
(lastResultTi... | java | {
"resource": ""
} |
q163337 | Partitioner.getSize | train | public static PartitionSize getSize(String name) {
for(PartitionSize pa : sizes) {
if(pa.name().equals(name)) {
return pa;
}
}
return twoYearSize;
} | java | {
"resource": ""
} |
q163338 | Partitioner.getSize | train | public PartitionSize getSize(Date first, Date last, int maxP) {
long diffMS = last.getTime() - first.getTime();
for(PartitionSize pa : sizes) {
long maxMS = maxP * pa.intervalMS();
if(maxMS > diffMS) {
return pa;
}
}
return twoYearSize;
} | java | {
"resource": ""
} |
q163339 | Partitioner.getRange | train | public List<Partition<T>> getRange(PartitionSize size, Date start,
Date end) {
// logDates("Constructing partitions Size(" + size.name() + ")",start,end);
// Date origStart = new Date(start.getTime());
List<Partition<T>> partitions = new ArrayList<Partition<T>>();
Calendar cStart = Calendar.getInstance(TZ_UTC... | java | {
"resource": ""
} |
q163340 | Partitioner.populate | train | public void populate(List<Partition<T>> partitions,
Iterator<T> itr) {
int idx = 0;
int size = partitions.size();
T element = null;
while(idx < size) {
Partition<T> partition = partitions.get(idx);
if(element == null) {
if(itr.hasNext()) {
element = itr.next();
} else {
// all done
... | java | {
"resource": ""
} |
q163341 | RequestMapper.addRequestHandler | train | public void addRequestHandler(int port, String host, String path,
RequestHandler requestHandler) {
Integer portInt = Integer.valueOf(port);
PortMapper portMapper = portMap.get(portInt);
if (portMapper == null) {
portMapper = new PortMapper(portInt);
portMap.put(portInt, portMapper);
}
portMapper.add... | java | {
"resource": ""
} |
q163342 | RequestMapper.handleRequest | train | public boolean handleRequest(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
boolean handled = false;
// Internally UIResults.forward(), don't handle here
if (request.getAttribute(UIResults.FERRET_NAME) != null) {
return false;
}
if (globalPreReques... | java | {
"resource": ""
} |
q163343 | RequestMapper.shutdown | train | public void shutdown() {
for (ShutdownListener shutdownListener : shutdownListeners) {
try {
shutdownListener.shutdown();
} catch(Exception e) {
LOGGER.severe("failed shutdown"+e.getMessage());
}
}
} | java | {
"resource": ""
} |
q163344 | AnsiPrintStream.processCharsetSelect | train | private boolean processCharsetSelect(ArrayList<Object> options) {
int set = optionInt(options, 0);
char seq = ((Character) options.get(1)).charValue();
processCharsetSelect(set, seq);
return true;
} | java | {
"resource": ""
} |
q163345 | AnsiRenderer.render | train | public static Appendable render(final String input, Appendable target) throws IOException {
int i = 0;
int j, k;
while (true) {
j = input.indexOf(BEGIN_TOKEN, i);
if (j == -1) {
if (i == 0) {
target.append(input);
... | java | {
"resource": ""
} |
q163346 | TimeBasedOneTimePasswordHelper.zeroPrepend | train | static String zeroPrepend(long num, int digits) {
String numStr = Long.toString(num);
if (numStr.length() >= digits) {
return numStr;
} else {
return String.format("%0" + digits + "d", num);
}
} | java | {
"resource": ""
} |
q163347 | TimeBasedOneTimePasswordHelper.decodeBase32 | train | static byte[] decodeBase32(String str) {
// each base-32 character encodes 5 bits
int numBytes = ((str.length() * 5) + 7) / 8;
byte[] result = new byte[numBytes];
int resultIndex = 0;
int which = 0;
int working = 0;
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
int val;
if (ch... | java | {
"resource": ""
} |
q163348 | AbstractNode.getName | train | @Override
public final String getName() {
String name = getProperty(AbstractNode.name);
if (name == null) {
name = getUuid();
}
return name;
} | java | {
"resource": ""
} |
q163349 | AbstractNode.getPropertyKeys | train | @Override
public Set<PropertyKey> getPropertyKeys(final String propertyView) {
// check for custom view in content-type field
if (securityContext != null && securityContext.hasCustomView()) {
final Set<PropertyKey> keys = new LinkedHashSet<>(StructrApp.getConfiguration().getPropertySet(entityType, PropertyVie... | java | {
"resource": ""
} |
q163350 | AbstractNode.getComparableProperty | train | @Override
public final <T> Comparable getComparableProperty(final PropertyKey<T> key) {
if (key != null) {
final T propertyValue = getProperty(key);
// check property converter
PropertyConverter<T, ?> converter = key.databaseConverter(securityContext, this);
if (converter != null) {
try {
re... | java | {
"resource": ""
} |
q163351 | AbstractNode.getRelationshipInfo | train | public final Map<String, Long> getRelationshipInfo(final Direction dir) throws FrameworkException {
return StructrApp.getInstance(securityContext).command(NodeRelationshipStatisticsCommand.class).execute(this, dir);
} | java | {
"resource": ""
} |
q163352 | AbstractNode.getOwnerNode | train | @Override
public final Principal getOwnerNode() {
if (cachedOwnerNode == null) {
final Ownership ownership = getIncomingRelationshipAsSuperUser(PrincipalOwnsNode.class);
if (ownership != null) {
Principal principal = ownership.getSourceNode();
cachedOwnerNode = (Principal) principal;
}
}
ret... | java | {
"resource": ""
} |
q163353 | AbstractNode.hasRelationship | train | public final <A extends NodeInterface, B extends NodeInterface, S extends Source, T extends Target> boolean hasRelationship(final Class<? extends Relation<A, B, S, T>> type) {
return this.getRelationships(type).iterator().hasNext();
} | java | {
"resource": ""
} |
q163354 | AbstractNode.propagationAllowed | train | private boolean propagationAllowed(final AbstractNode thisNode, final RelationshipInterface rel, final SchemaRelationshipNode.Direction propagationDirection, final boolean doLog) {
// early exit
if (propagationDirection.equals(SchemaRelationshipNode.Direction.Both)) {
return true;
}
// early exit
if (pro... | java | {
"resource": ""
} |
q163355 | AgentService.createAgent | train | private Agent createAgent(Task forTask) {
logger.debug("Creating new agent for task {}", forTask.getClass().getSimpleName());
Agent agent = null;
try {
agent = lookupAgent(forTask);
if (agent != null) {
// register us in agent..
agent.setAgentService(this);
}
} catch (Throwable t) {
... | java | {
"resource": ""
} |
q163356 | ReferenceGroup.getDirectAccessReferenceGroup | train | public <T> PropertyKey<T> getDirectAccessReferenceGroup(String name, Class<T> type) {
if (!propertyKeys.containsKey(name)) {
throw new IllegalArgumentException("ReferenceGroup " + dbName + " does not contain grouped property " + name + "!");
}
return new GenericProperty(propertyKeys.get(name).dbName());
} | java | {
"resource": ""
} |
q163357 | UiAuthenticator.checkExternalAuthentication | train | protected Principal checkExternalAuthentication(final HttpServletRequest request, final HttpServletResponse response) throws FrameworkException {
final String path = PathHelper.clean(request.getPathInfo());
final String[] uriParts = PathHelper.getParts(path);
logger.debug("Checking external authentication ...")... | java | {
"resource": ""
} |
q163358 | ValidationHelper.isValidStringMinLength | train | public static boolean isValidStringMinLength(final GraphObject node, final PropertyKey<String> key, final int minLength, final ErrorBuffer errorBuffer) {
String value = node.getProperty(key);
String type = node.getType();
if (StringUtils.isNotBlank(value)) {
if (value.length() >= minLength) {
return t... | java | {
"resource": ""
} |
q163359 | LinkedListNodeImpl.listGetPrevious | train | @Override
public T listGetPrevious(final T currentElement) {
Relation<T, T, OneStartpoint<T>, OneEndpoint<T>> prevRel = currentElement.getIncomingRelationship(getSiblingLinkType());
if (prevRel != null) {
return (T)prevRel.getSourceNode();
}
return null;
} | java | {
"resource": ""
} |
q163360 | LinkedListNodeImpl.listGetNext | train | @Override
public T listGetNext(final T currentElement) {
Relation<T, T, OneStartpoint<T>, OneEndpoint<T>> nextRel = currentElement.getOutgoingRelationship(getSiblingLinkType());
if (nextRel != null) {
return (T)nextRel.getTargetNode();
}
return null;
} | java | {
"resource": ""
} |
q163361 | LinkedListNodeImpl.listInsertBefore | train | @Override
public void listInsertBefore(final T currentElement, final T newElement) throws FrameworkException {
if (currentElement.getUuid().equals(newElement.getUuid())) {
throw new IllegalStateException("Cannot link a node to itself!");
}
final T previousElement = listGetPrevious(currentElement);
if (pre... | java | {
"resource": ""
} |
q163362 | LinkedListNodeImpl.listInsertAfter | train | @Override
public void listInsertAfter(final T currentElement, final T newElement) throws FrameworkException {
if (currentElement.getUuid().equals(newElement.getUuid())) {
throw new IllegalStateException("Cannot link a node to itself!");
}
final T next = listGetNext(currentElement);
if (next == null) {
... | java | {
"resource": ""
} |
q163363 | LinkedListNodeImpl.listRemove | train | @Override
public void listRemove(final T currentElement) throws FrameworkException {
final T previousElement = listGetPrevious(currentElement);
final T nextElement = listGetNext(currentElement);
if (currentElement != null) {
if (previousElement != null) {
unlinkNodes(getSiblingLinkType(), previousE... | java | {
"resource": ""
} |
q163364 | XMLHandler.handleSetProperty | train | private void handleSetProperty(final Element element, final Map<String, Object> entityData, final Map<String, Object> config) {
String propertyName = (String)config.get(PROPERTY_NAME);
if (propertyName == null) {
propertyName = element.tagName;
}
entityData.put(propertyName, element.text);
} | java | {
"resource": ""
} |
q163365 | StructrSchema.createFromDatabase | train | public static JsonSchema createFromDatabase(final App app, final List<String> types) throws FrameworkException, URISyntaxException {
try (final Tx tx = app.tx()) {
final JsonSchema schema = StructrSchemaDefinition.initializeFromDatabase(app, types);
tx.success();
return schema;
}
} | java | {
"resource": ""
} |
q163366 | StructrSchema.createFromSource | train | public static JsonSchema createFromSource(final String source) throws InvalidSchemaException, URISyntaxException {
return StructrSchema.createFromSource(new StringReader(source));
} | java | {
"resource": ""
} |
q163367 | StructrSchema.createFromSource | train | public static JsonSchema createFromSource(final Reader reader) throws InvalidSchemaException, URISyntaxException {
final Gson gson = new GsonBuilder().create();
final Map<String, Object> rawData = gson.fromJson(reader, Map.class);
return StructrSchemaDefinition.initializeFromSource(rawDa... | java | {
"resource": ""
} |
q163368 | StructrSchema.replaceDatabaseSchema | train | public static void replaceDatabaseSchema(final App app, final JsonSchema newSchema) throws FrameworkException, URISyntaxException {
Services.getInstance().setOverridingSchemaTypesAllowed(true);
try (final Tx tx = app.tx()) {
for (final SchemaRelationshipNode schemaRelationship : app.nodeQuery(SchemaRelationsh... | java | {
"resource": ""
} |
q163369 | StructrSchema.extendDatabaseSchema | train | public static void extendDatabaseSchema(final App app, final JsonSchema newSchema) throws FrameworkException, URISyntaxException {
try (final Tx tx = app.tx()) {
newSchema.createDatabaseSchema(app, JsonSchema.ImportMode.extend);
tx.success();
}
} | java | {
"resource": ""
} |
q163370 | Char.eatPercentage | train | public static char eatPercentage(String a, int[] n) {
// Length 0
if (!a.startsWith("%") || a.length() < 3) {
n[0] = 0;
return ((char) 0);
}
char c;
// Try to parse first char
try {
c = (char) Integer.parseInt(a.substring(1, 3), 16);
} catch (Exception e) {
n[0] = -1;... | java | {
"resource": ""
} |
q163371 | Char.eatAmpersand | train | public static char eatAmpersand(String a, int[] n) {
n[0] = 0;
if (!a.startsWith("&")) return ((char) 0);
// Seek to ';'
// We also accept spaces and the end of the String as a delimiter
while (n[0] < a.length() && !Character.isSpaceChar(a.charAt(n[0])) && a.charAt(n[0]) != ';')
n[0]++;
if... | java | {
"resource": ""
} |
q163372 | Char.eatUtf8 | train | public static char eatUtf8(String a, int[] n) {
if (a.length() == 0) {
n[0] = 0;
return ((char) 0);
}
n[0] = Utf8Length(a.charAt(0));
if (a.length() >= n[0]) {
switch (n[0]) {
case 1:
return (a.charAt(0));
case 2:
if ((a.charAt(1) & 0xC0) != 0x80) br... | java | {
"resource": ""
} |
q163373 | Char.decodeUTF8 | train | public static String decodeUTF8(String s) {
StringBuilder result = new StringBuilder();
int[] eatLength = new int[1];
while (s.length() != 0) {
char c = eatUtf8(s, eatLength);
if (eatLength[0] != -1) {
result.append(c);
s = s.substring(eatLength[0]);
} else {
result... | java | {
"resource": ""
} |
q163374 | Char.decodePercentage | train | public static String decodePercentage(String s) {
StringBuilder result = new StringBuilder();
int[] eatLength = new int[1];
while (s.length() != 0) {
char c = eatPercentage(s, eatLength);
if (eatLength[0] > 1) {
result.append(c);
s = s.substring(eatLength[0]);
} else {
... | java | {
"resource": ""
} |
q163375 | Char.decodeAmpersand | train | public static String decodeAmpersand(String s) {
if(s==null || s.indexOf('&')==-1) return(s);
StringBuilder result = new StringBuilder();
int[] eatLength = new int[1];// add this in order to multithread safe
while (s.length() != 0) {
char c = eatAmpersand(s, eatLength);
if (eatLength[0] > 1)... | java | {
"resource": ""
} |
q163376 | Char.decodeBackslash | train | public static String decodeBackslash(String s) {
if(s==null || s.indexOf('\\')==-1) return(s);
StringBuilder result = new StringBuilder();
int[] eatLength = new int[1];
while (s.length() != 0) {
char c = eatBackslash(s, eatLength);
if (eatLength[0] > 1) {
result.append(c);
s =... | java | {
"resource": ""
} |
q163377 | Char.encodeBackslash | train | public static String encodeBackslash(CharSequence s, Legal legal) {
StringBuilder b=new StringBuilder((int)(s.length()*1.5));
for(int i=0;i<s.length();i++) {
if(legal.isLegal(s.charAt(i))) {
b.append(s.charAt(i));
} else {
if(charToBackslash.containsKey(s.charAt(i))) {
b.append(charToBackslash.get(s.cha... | java | {
"resource": ""
} |
q163378 | Char.eatBackslash | train | public static char eatBackslash(String a, int[] n) {
if (!a.startsWith("\\")) {
n[0] = 0;
return ((char) 0);
}
// Unicodes BS u XXXX
if (a.startsWith("\\u")) {
try {
n[0] = 6;
return ((char) Integer.parseInt(a.substring(2, 6), 16));
} catch (Exception e) {
... | java | {
"resource": ""
} |
q163379 | Char.decode | train | public static String decode(String s) {
StringBuilder b = new StringBuilder();
int[] eatLength = new int[1];
while (s.length() > 0) {
char c = eatPercentage(s, eatLength);
if (eatLength[0] <= 0) {
c = eatAmpersand(s, eatLength);
if (eatLength[0] <= 0) {
c = eatBackslash... | java | {
"resource": ""
} |
q163380 | Char.encodeXmlAttribute | train | public static String encodeXmlAttribute(String str) {
if (str == null) return null;
int len = str.length();
if (len == 0) return str;
StringBuffer encoded = new StringBuffer();
for (int i = 0; i < len; i++) {
char c = str.charAt(i);
if (c == '<') encoded.append("<");
else if (c ... | java | {
"resource": ""
} |
q163381 | Char.encodeURIPathComponent | train | public static String encodeURIPathComponent(String s) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
result.append(Char.encodeURIPathComponent(s.charAt(i)));
}
return (result.toString());
} | java | {
"resource": ""
} |
q163382 | Char.encodeURIPathComponentXML | train | public static String encodeURIPathComponentXML(String s) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '&') result.append(Char.encodePercentage(s.charAt(i)));
else if (s.charAt(i) == '"') result.append(Char.encodePercentage(s.charAt(i)));
... | java | {
"resource": ""
} |
q163383 | Char.encodeUTF8 | train | public static String encodeUTF8(String c) {
StringBuilder r = new StringBuilder();
for (int i = 0; i < c.length(); i++) {
r.append(encodeUTF8(c.charAt(i)));
}
return (r.toString());
} | java | {
"resource": ""
} |
q163384 | Char.normalize | train | public static String normalize(String s) {
StringBuilder b = new StringBuilder();
for (int i = 0; i < s.length(); i++)
b.append(normalize(s.charAt(i)));
return (b.toString());
} | java | {
"resource": ""
} |
q163385 | Char.cutLast | train | public static String cutLast(String s) {
return (s.length() == 0 ? "" : s.substring(0, s.length() - 1));
} | java | {
"resource": ""
} |
q163386 | Char.hexAll | train | public static String hexAll(String s) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
result.append(Integer.toHexString(s.charAt(i)).toUpperCase()).append(' ');
}
return (result.toString());
} | java | {
"resource": ""
} |
q163387 | Char.lowCaseFirst | train | public static String lowCaseFirst(String s) {
if (s == null || s.length() == 0) return (s);
return (Character.toLowerCase(s.charAt(0)) + s.substring(1));
} | java | {
"resource": ""
} |
q163388 | Char.truncate | train | public static CharSequence truncate(CharSequence s, int len) {
if (s.length() == len) return (s);
if (s.length() > len) return (s.subSequence(0, len));
StringBuilder result = new StringBuilder(s);
while (result.length() < len)
result.append(' ');
return (result);
} | java | {
"resource": ""
} |
q163389 | Char.capitalize | train | public static String capitalize(String s) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (i == 0 || i > 0 && !Character.isLetterOrDigit(s.charAt(i - 1))) c = Character.toUpperCase(c);
else c = Character.toLowerCase(c);
result... | java | {
"resource": ""
} |
q163390 | Char.endsWith | train | public static boolean endsWith(CharSequence s, String end) {
return (s.length() >= end.length() && s.subSequence(s.length() - end.length(), s.length()).equals(end));
} | java | {
"resource": ""
} |
q163391 | StructrOAuthClient.getServer | train | public static StructrOAuthClient getServer(final String name) {
String configuredOauthServers = Settings.OAuthServers.getValue();
String[] authServers = configuredOauthServers.split(" ");
for (String authServer : authServers) {
if (authServer.equals(name)) {
String authLocation = Settings.getOrCreate... | java | {
"resource": ""
} |
q163392 | FileHelper.transformFile | train | public static <T extends File> T transformFile(final SecurityContext securityContext, final String uuid, final Class<T> fileType) throws FrameworkException, IOException {
AbstractFile existingFile = getFileByUuid(securityContext, uuid);
if (existingFile != null) {
existingFile.unlockSystemPropertiesOnce();
... | java | {
"resource": ""
} |
q163393 | FileHelper.createFileBase64 | train | public static <T extends File> T createFileBase64(final SecurityContext securityContext, final String rawData, final Class<T> t) throws FrameworkException, IOException {
Base64URIData uriData = new Base64URIData(rawData);
return createFile(securityContext, uriData.getBinaryData(), uriData.getContentType(), t);
... | java | {
"resource": ""
} |
q163394 | FileHelper.createFile | train | public static <T extends File> T createFile(final SecurityContext securityContext, final InputStream fileStream, final String contentType, final Class<T> fileType, final String name)
throws FrameworkException, IOException {
return createFile(securityContext, fileStream, contentType, fileType, name, null);
} | java | {
"resource": ""
} |
q163395 | FileHelper.decodeAndSetFileData | train | public static void decodeAndSetFileData(final File file, final String rawData) throws FrameworkException, IOException {
Base64URIData uriData = new Base64URIData(rawData);
setFileData(file, uriData.getBinaryData(), uriData.getContentType(), true);
} | java | {
"resource": ""
} |
q163396 | FileHelper.setFileData | train | public static void setFileData(final File file, final InputStream fileStream, final String contentType) throws FrameworkException, IOException {
FileHelper.writeToFile(file, fileStream);
setFileProperties(file, contentType);
} | java | {
"resource": ""
} |
q163397 | FileHelper.setFileProperties | train | public static void setFileProperties (final File file, final String contentType) throws IOException, FrameworkException {
final java.io.File fileOnDisk = file.getFileOnDisk(false);
final PropertyMap map = new PropertyMap();
map.put(StructrApp.key(File.class, "contentType"), contentType != null ? content... | java | {
"resource": ""
} |
q163398 | FileHelper.setFileProperties | train | public static void setFileProperties (File fileNode) throws FrameworkException {
final PropertyMap properties = new PropertyMap();
String id = fileNode.getProperty(GraphObject.id);
if (id == null) {
final String newUuid = UUID.randomUUID().toString().replaceAll("[\\-]+", "");
id = newUuid;
fileNode.u... | java | {
"resource": ""
} |
q163399 | FileHelper.getChecksums | train | private static PropertyMap getChecksums(final File file, final java.io.File fileOnDisk) throws IOException {
final PropertyMap propertiesWithChecksums = new PropertyMap();
Folder parentFolder = file.getParent();
String checksums = null;
while (parentFolder != null && checksums == null) {
checksums = p... | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.