code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static String readFileFromClasspath(String file) {
logger.trace("Reading file [{}]...", file);
String content = null;
try (InputStream asStream = SettingsReader.class.getClassLoader().getResourceAsStream(file)) {
if (asStream == null) {
logger.trace("Can not find [{}] in class loader.", file);
... | java |
public static String[] getResources(final String root) throws URISyntaxException, IOException {
logger.trace("Reading classpath resources from {}", root);
URL dirURL = ResourceList.class.getClassLoader().getResource(root);
if (dirURL != null && dirURL.getProtocol().equals("file")) {
... | java |
public static List<String> findTemplates(String root) throws IOException, URISyntaxException {
if (root == null) {
return findTemplates();
}
logger.debug("Looking for templates in classpath under [{}].", root);
final List<String> templateNames = new ArrayList<>();
S... | java |
@Deprecated
public static void createIndex(Client client, String root, String index, boolean force) throws Exception {
String settings = IndexSettingsReader.readSettings(root, index);
createIndexWithSettings(client, index, settings, force);
} | java |
public static void createIndex(RestClient client, String index, boolean force) throws Exception {
String settings = IndexSettingsReader.readSettings(index);
createIndexWithSettings(client, index, settings, force);
} | java |
private void inflateWidgetLayout(Context context, int layoutId) {
inflate(context, layoutId, this);
floatingLabel = (TextView) findViewById(R.id.flw_floating_label);
if (floatingLabel == null) {
throw new RuntimeException("Your layout must have a TextView whose ID is @id/flw_floatin... | java |
public B css(String... classes) {
if (classes != null) {
List<String> failSafeClasses = new ArrayList<>();
for (String c : classes) {
if (c != null) {
if (c.contains(" ")) {
failSafeClasses.addAll(asList(c.split(" ")));
... | java |
public B attr(String name, String value) {
get().setAttribute(name, value);
return that();
} | java |
public <V extends Event> B on(EventType<V, ?> type, EventCallbackFn<V> callback) {
bind(get(), type, callback);
return that();
} | java |
public void setInputWidgetText(CharSequence text, TextView.BufferType type) {
getInputWidget().setText(text, type);
} | java |
protected void onTextChanged(String s) {
if (!isFloatOnFocusEnabled()) {
if (s.length() == 0) {
anchorLabel();
} else {
floatLabel();
}
}
if (editTextListener != null) editTextListener.onTextChanged(this, s);
} | java |
public static Bitmap applyColor(Bitmap bitmap, int accentColor) {
int r = Color.red(accentColor);
int g = Color.green(accentColor);
int b = Color.blue(accentColor);
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int[] pixels = new int[width * height];
bitmap.getPixels(pixels, 0, width,... | java |
public static Bitmap changeTintColor(Bitmap bitmap, int originalColor, int destinationColor) {
// original tint color
int[] o = new int[] {
Color.red(originalColor),
Color.green(originalColor),
Color.blue(originalColor) };
// destination tint color
int[] d = new int[] {
Color.red(destinationColo... | java |
public static Bitmap processTintTransformationMap(Bitmap transformationMap, int tintColor) {
// tint color
int[] t = new int[] {
Color.red(tintColor),
Color.green(tintColor),
Color.blue(tintColor) };
int width = transformationMap.getWidth();
int height = transformationMap.getHeight();
int[] pix... | java |
public static void writeToFile(Bitmap bitmap, String dir, String filename) throws FileNotFoundException, IOException {
File sdCard = Environment.getExternalStorageDirectory();
File dirFile = new File (sdCard.getAbsolutePath() + "/" + dir);
dirFile.mkdirs();
File f = new File(dirFile, filename);
FileOutputStre... | java |
public static int getIdentifier(String name) {
Resources res = Resources.getSystem();
return res.getIdentifier(name, TYPE_ID, NATIVE_PACKAGE);
} | java |
public static int getStringIdentifier(String name) {
Resources res = Resources.getSystem();
return res.getIdentifier(name, TYPE_STRING, NATIVE_PACKAGE);
} | java |
public static int getDrawableIdentifier(String name) {
Resources res = Resources.getSystem();
return res.getIdentifier(name, TYPE_DRAWABLE, NATIVE_PACKAGE);
} | java |
static TodoItemElement create(Provider<ApplicationElement> application, TodoItemRepository repository) {
return new Templated_TodoItemElement(application, repository);
} | java |
public void addTintResourceId(int resId) {
if (mCustomTintDrawableIds == null)
mCustomTintDrawableIds = new ArrayList<Integer>();
mCustomTintDrawableIds.add(resId);
} | java |
public void addTintTransformationResourceId(int resId) {
if (mCustomTransformationDrawableIds == null)
mCustomTransformationDrawableIds = new ArrayList<Integer>();
mCustomTransformationDrawableIds.add(resId);
} | java |
private InputStream getTintendResourceStream(int id, TypedValue value, int color) {
Bitmap bitmap = getBitmapFromResource(id, value);
bitmap = BitmapUtils.applyColor(bitmap, color);
return getStreamFromBitmap(bitmap);
} | java |
private InputStream getTintTransformationResourceStream(int id, TypedValue value, int color) {
Bitmap bitmap = getBitmapFromResource(id, value);
bitmap = BitmapUtils.processTintTransformationMap(bitmap, color);
return getStreamFromBitmap(bitmap);
} | java |
public Collection<ItemT> getSelectedItems() {
if (availableItems == null || selectedIndices == null || selectedIndices.length == 0) {
return new ArrayList<ItemT>(0);
}
ArrayList<ItemT> items = new ArrayList<ItemT>(selectedIndices.length);
for (int index : selectedIndices) {
... | java |
protected static Bundle buildCommonArgsBundle(int pickerId, String title, String positiveButtonText, String negativeButtonText, boolean enableMultipleSelection, int[] selectedItemIndices) {
Bundle args = new Bundle();
args.putInt(ARG_PICKER_ID, pickerId);
args.putString(ARG_TITLE, title);
... | java |
@Override
public void draw(Canvas canvas) {
float width = canvas.getWidth();
float margin = (width / 3) + mState.mMarginSide;
float posY = canvas.getHeight() - mState.mMarginBottom;
canvas.drawLine(margin, posY, width - margin, posY, mPaint);
} | java |
static void addAttachObserver(HTMLElement element, ObserverCallback callback) {
if (!ready) {
startObserving();
}
attachObservers.add(createObserver(element, callback, ATTACH_UID_KEY));
} | java |
static void addDetachObserver(HTMLElement element, ObserverCallback callback) {
if (!ready) {
startObserving();
}
detachObservers.add(createObserver(element, callback, DETACH_UID_KEY));
} | java |
public static <DateInstantT extends DateInstant> DatePickerFragment newInstance(int pickerId, DateInstantT selectedInstant) {
DatePickerFragment f = new DatePickerFragment();
Bundle args = new Bundle();
args.putInt(ARG_PICKER_ID, pickerId);
args.putParcelable(ARG_SELECTED_INSTANT, selec... | java |
private void abortWithError(Element element, String msg, Object... args) throws AbortProcessingException {
error(element, msg, args);
throw new AbortProcessingException();
} | java |
public static AccentPalette getPalette(Context context) {
Resources resources = context.getResources();
if (!(resources instanceof AccentResources))
return null;
return ((AccentResources)resources).getPalette();
} | java |
public void prepareDialog(Context c, Window window) {
if (mDividerPainter == null)
mDividerPainter = initPainter(c, mOverrideColor);
mDividerPainter.paint(window);
} | java |
public static <E extends HTMLElement> EmptyContentBuilder<E> emptyElement(String tag, Class<E> type) {
return emptyElement(() -> createElement(tag, type));
} | java |
public static <E extends HTMLElement> TextContentBuilder<E> textElement(String tag, Class<E> type) {
return new TextContentBuilder<>(createElement(tag, type));
} | java |
public static <E extends HTMLElement> HtmlContentBuilder<E> htmlElement(String tag, Class<E> type) {
return new HtmlContentBuilder<>(createElement(tag, type));
} | java |
public static <E> Stream<E> stream(JsArrayLike<E> nodes) {
if (nodes == null) {
return Stream.empty();
} else {
return StreamSupport.stream(spliteratorUnknownSize(iterator(nodes), 0), false);
}
} | java |
public static Stream<Node> stream(Node parent) {
if (parent == null) {
return Stream.empty();
} else {
return StreamSupport.stream(spliteratorUnknownSize(iterator(parent), 0), false);
}
} | java |
public static void lazyAppend(Element parent, Element child) {
if (!parent.contains(child)) {
parent.appendChild(child);
}
} | java |
public static void insertAfter(Element newElement, Element after) {
after.parentNode.insertBefore(newElement, after.nextSibling);
} | java |
public static void lazyInsertAfter(Element newElement, Element after) {
if (!after.parentNode.contains(newElement)) {
after.parentNode.insertBefore(newElement, after.nextSibling);
}
} | java |
public static void insertBefore(Element newElement, Element before) {
before.parentNode.insertBefore(newElement, before);
} | java |
public static void lazyInsertBefore(Element newElement, Element before) {
if (!before.parentNode.contains(newElement)) {
before.parentNode.insertBefore(newElement, before);
}
} | java |
public static boolean failSafeRemoveFromParent(Element element) {
return failSafeRemove(element != null ? element.parentNode : null, element);
} | java |
public static boolean failSafeRemove(Node parent, Element child) {
//noinspection SimplifiableIfStatement
if (parent != null && child != null && parent.contains(child)) {
return parent.removeChild(child) != null;
}
return false;
} | java |
public static void onAttach(HTMLElement element, ObserverCallback callback) {
if (element != null) {
BodyObserver.addAttachObserver(element, callback);
}
} | java |
public static void onDetach(HTMLElement element, ObserverCallback callback) {
if (element != null) {
BodyObserver.addDetachObserver(element, callback);
}
} | java |
public void setSwitchTextAppearance(Context context, int resid) {
TypedArray appearance = context.obtainStyledAttributes(resid,
R.styleable.TextAppearanceAccentSwitch);
ColorStateList colors;
int ts;
colors = appearance
.getColorStateList(R.styleable.TextAppearanceAccentSwitch_android_textColor);
if... | java |
private void stopDrag(MotionEvent ev) {
mTouchMode = TOUCH_MODE_IDLE;
// Up and not canceled, also checks the switch has not been disabled
// during the drag
boolean commitChange = ev.getAction() == MotionEvent.ACTION_UP
&& isEnabled();
cancelSuperTouch(ev);
if (commitChange) {
boolean newState;
... | java |
public static <TimeInstantT extends TimeInstant> TimePickerFragment newInstance(int pickerId, TimeInstantT selectedInstant) {
TimePickerFragment f = new TimePickerFragment();
Bundle args = new Bundle();
args.putInt(ARG_PICKER_ID, pickerId);
args.putParcelable(ARG_SELECTED_INSTANT, selec... | java |
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private void setBackground(View view, Drawable drawable) {
if (Build.VERSION.SDK_INT >= SET_DRAWABLE_MIN_SDK)
view.setBackground(drawable);
else
view.setBackgroundDrawable(drawable);
} | java |
void sendAccessibilityEvent(View view) {
// Since the view is still not attached we create, populate,
// and send the event directly since we do not know when it
// will be attached and posting commands is not as clean.
AccessibilityManager accessibilityManager =
(Accessibility... | java |
public static String unescape(String string, char escape)
{
CharArrayWriter out = new CharArrayWriter(string.length());
for (int i = 0; i < string.length(); i++)
{
char c = string.charAt(i);
if (c == escape)
{
try
{
out.wri... | java |
public static String escape(String string, char escape, boolean isPath)
{
try
{
BitSet validChars = isPath ? URISaveEx : URISave;
byte[] bytes = string.getBytes("utf-8");
StringBuffer out = new StringBuffer(bytes.length);
for (int i = 0; i < bytes.length; i++)
... | java |
public static String relativizePath(String path, boolean withIndex)
{
if (path.startsWith("/"))
path = path.substring(1);
if (!withIndex && path.endsWith("]"))
{
int index = path.lastIndexOf('[');
return index == -1 ? path : path.substring(0, index);
}
... | java |
public static String removeIndexFromPath(String path)
{
if (path.endsWith("]"))
{
int index = path.lastIndexOf('[');
if (index != -1)
{
return path.substring(0, index);
}
}
return path;
} | java |
public static String pathOnly(String path)
{
String curPath = path;
curPath = curPath.substring(curPath.indexOf("/"));
curPath = curPath.substring(0, curPath.lastIndexOf("/"));
if ("".equals(curPath))
{
curPath = "/";
}
return curPath;
} | java |
public static String nameOnly(String path)
{
int index = path.lastIndexOf('/');
String name = index == -1 ? path : path.substring(index + 1);
if (name.endsWith("]"))
{
index = name.lastIndexOf('[');
return index == -1 ? name : name.substring(0, index);
}
... | java |
public static String getExtension(String filename)
{
int index = filename.lastIndexOf('.');
if (index >= 0)
{
return filename.substring(index + 1);
}
return "";
} | java |
protected boolean isPredecessor(NodeData mergeVersion, NodeData corrVersion) throws RepositoryException
{
SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();
PropertyData predecessorsProperty =
(PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Co... | java |
protected boolean isSuccessor(NodeData mergeVersion, NodeData corrVersion) throws RepositoryException
{
SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();
PropertyData successorsProperty =
(PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Consta... | java |
public PersistedNodeData read(ObjectReader in) throws UnknownClassIdException, IOException
{
// read id
int key;
if ((key = in.readInt()) != SerializationConstants.PERSISTED_NODE_DATA)
{
throw new UnknownClassIdException("There is unexpected class [" + key + "]");
}
QPat... | java |
protected void prepareRenamingApproachScripts() throws DBCleanException
{
cleaningScripts.addAll(getTablesRenamingScripts());
cleaningScripts.addAll(getDBInitializationScripts());
cleaningScripts.addAll(getFKRemovingScripts());
cleaningScripts.addAll(getConstraintsRemovingScripts());
cl... | java |
protected void prepareDroppingTablesApproachScripts() throws DBCleanException
{
cleaningScripts.addAll(getTablesDroppingScripts());
cleaningScripts.addAll(getDBInitializationScripts());
cleaningScripts.addAll(getFKRemovingScripts());
cleaningScripts.addAll(getIndexesDroppingScripts());
... | java |
protected void prepareSimpleCleaningApproachScripts()
{
cleaningScripts.addAll(getFKRemovingScripts());
cleaningScripts.addAll(getSingleDbWorkspaceCleaningScripts());
committingScripts.addAll(getFKAddingScripts());
rollbackingScripts.addAll(getFKAddingScripts());
} | java |
protected Collection<String> getFKRemovingScripts()
{
List<String> scripts = new ArrayList<String>();
String constraintName = "JCR_FK_" + itemTableSuffix + "_PARENT";
scripts.add("ALTER TABLE " + itemTableName + " " + constraintDroppingSyntax() + " " + constraintName);
return scripts;
} | java |
protected Collection<String> getFKAddingScripts()
{
List<String> scripts = new ArrayList<String>();
String constraintName =
"JCR_FK_" + itemTableSuffix + "_PARENT FOREIGN KEY(PARENT_ID) REFERENCES " + itemTableName + "(ID)";
scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT " ... | java |
protected Collection<String> getOldTablesDroppingScripts()
{
List<String> scripts = new ArrayList<String>();
scripts.add("DROP TABLE " + valueTableName + "_OLD");
scripts.add("DROP TABLE " + refTableName + "_OLD");
scripts.add("DROP TABLE " + itemTableName + "_OLD");
return scripts;
... | java |
protected Collection<String> getDBInitializationScripts() throws DBCleanException
{
String dbScripts;
try
{
dbScripts = DBInitializerHelper.prepareScripts(wsEntry, dialect);
}
catch (IOException e)
{
throw new DBCleanException(e);
}
catch (RepositoryC... | java |
public <T> List<T> getComponentInstancesOfType(Class<T> componentType)
{
return container.getComponentInstancesOfType(componentType);
} | java |
public int getState()
{
boolean hasSuspendedComponents = false;
boolean hasResumedComponents = false;
List<Suspendable> suspendableComponents = getComponentInstancesOfType(Suspendable.class);
for (Suspendable component : suspendableComponents)
{
if (component.isSuspended())
... | java |
public void setState(final int state) throws RepositoryException
{
// Need privileges to manage repository.
SecurityManager security = System.getSecurityManager();
if (security != null)
{
security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
}
try... | java |
private void suspend() throws RepositoryException
{
WorkspaceResumer workspaceResumer = getWorkspaceResumer();
if (workspaceResumer != null)
{
workspaceResumer.onSuspend();
}
List<Suspendable> components = getComponentInstancesOfType(Suspendable.class);
Comparator<Suspe... | java |
private void resume() throws RepositoryException
{
WorkspaceResumer workspaceResumer = getWorkspaceResumer();
if (workspaceResumer != null)
{
workspaceResumer.onResume();
}
// components should be resumed in reverse order
List<Suspendable> components = getComponentInstan... | java |
private Set<QName> propertyNames(HierarchicalProperty body)
{
HashSet<QName> names = new HashSet<QName>();
HierarchicalProperty propBody = body.getChild(PropertyConstants.DAV_ALLPROP_INCLUDE);
if (propBody != null)
{
names.add(PropertyConstants.DAV_ALLPROP_INCLUDE);
... | java |
protected String getCurrentFolderPath(GenericWebAppContext context)
{
// To limit browsing set Servlet init param "digitalAssetsPath" with desired JCR path
String rootFolderStr =
(String)context.get("org.exoplatform.frameworks.jcr.command.web.fckeditor.digitalAssetsPath");
if (rootFolderS... | java |
protected String makeRESTPath(String repoName, String workspace, String resource)
{
final StringBuilder sb = new StringBuilder(512);
ExoContainer container = ExoContainerContext.getCurrentContainerIfPresent();
if (container instanceof PortalContainer)
{
PortalContainer pContainer = (... | java |
protected String getLockToken(String tokenHash)
{
for (String token : tokens.keySet())
{
if (tokens.get(token).equals(tokenHash))
{
return token;
}
}
return null;
} | java |
public LockData getPendingLock(String nodeId)
{
if (pendingLocks.contains(nodeId))
{
return lockedNodes.get(nodeId);
}
else
{
return null;
}
} | java |
public int getNodeIndex(NodeData parentData, InternalQName name, String skipIdentifier)
throws PathNotFoundException, IllegalPathException, RepositoryException
{
if (name instanceof QPathEntry)
{
name = new InternalQName(name.getNamespace(), name.getName());
}
int newIn... | java |
public void setAncestorToSave(QPath newAncestorToSave)
{
if (!ancestorToSave.equals(newAncestorToSave))
{
isNeedReloadAncestorToSave = true;
}
this.ancestorToSave = newAncestorToSave;
} | java |
protected void createVersionHistory(ImportNodeData nodeData) throws RepositoryException
{
// Generate new VersionHistoryIdentifier and BaseVersionIdentifier
// if uuid changed after UC
boolean newVersionHistory = nodeData.isNewIdentifer() || !nodeData.isContainsVersionhistory();
if (newVersio... | java |
protected void checkReferenceable(ImportNodeData currentNodeInfo, String olUuid) throws RepositoryException
{
// if node is in version storage - do not assign new id from jcr:uuid
// property
if (Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3 <= currentNodeInfo.getQPath().getDepth()
&& ... | java |
private List<ItemState> getItemStatesList(NodeData parentData, InternalQName name, int state, String skipIdentifier)
{
List<ItemState> states = new ArrayList<ItemState>();
for (ItemState itemState : changesLog.getAllStates())
{
ItemData stateData = itemState.getData();
if (isParen... | java |
protected ItemState getLastItemState(String identifer)
{
List<ItemState> allStates = changesLog.getAllStates();
for (int i = allStates.size() - 1; i >= 0; i--)
{
ItemState state = allStates.get(i);
if (state.getData().getIdentifier().equals(identifer))
return state;
... | java |
private void removeExisted(NodeData sameUuidItem) throws RepositoryException, ConstraintViolationException,
PathNotFoundException
{
if (!nodeTypeDataManager.isNodeType(Constants.MIX_REFERENCEABLE, sameUuidItem.getPrimaryTypeName(), sameUuidItem
.getMixinTypeNames()))
{
throw new ... | java |
private void removeVersionHistory(NodeData mixVersionableNode) throws RepositoryException,
ConstraintViolationException, VersionException
{
try
{
PropertyData vhpd =
(PropertyData)dataConsumer.getItemData(mixVersionableNode, new QPathEntry(Constants.JCR_VERSIONHISTORY, 1),
... | java |
protected void notifyListeners()
{
synchronized (listeners)
{
Thread notifier = new NotifyThread(listeners.toArray(new BackupJobListener[listeners.size()]), this);
notifier.start();
}
} | java |
protected void notifyError(String message, Throwable error)
{
synchronized (listeners)
{
Thread notifier =
new ErrorNotifyThread(listeners.toArray(new BackupJobListener[listeners.size()]), this, message, error);
notifier.start();
}
} | java |
private UserProfile readProfile(Session session, String userName) throws Exception
{
Node profileNode;
try
{
profileNode = utils.getProfileNode(session, userName);
}
catch (PathNotFoundException e)
{
return null;
}
return readProfile(userName, profil... | java |
private UserProfile removeUserProfile(Session session, String userName, boolean broadcast) throws Exception
{
Node profileNode;
try
{
profileNode = utils.getProfileNode(session, userName);
}
catch (PathNotFoundException e)
{
return null;
}
UserProfil... | java |
void migrateProfile(Node oldUserNode) throws Exception
{
UserProfile userProfile = new UserProfileImpl(oldUserNode.getName());
Node attrNode = null;
try
{
attrNode = oldUserNode.getNode(JCROrganizationServiceImpl.JOS_PROFILE + "/" + MigrationTool.JOS_ATTRIBUTES);
}
catch... | java |
private void saveUserProfile(Session session, UserProfile profile, boolean broadcast) throws RepositoryException,
Exception
{
Node userNode = utils.getUserNode(session, profile.getUserName());
Node profileNode = getProfileNode(userNode);
boolean isNewProfile = profileNode.isNew();
if ... | java |
private Node getProfileNode(Node userNode) throws RepositoryException
{
try
{
return userNode.getNode(JCROrganizationServiceImpl.JOS_PROFILE);
}
catch (PathNotFoundException e)
{
return userNode.addNode(JCROrganizationServiceImpl.JOS_PROFILE);
}
} | java |
private UserProfile readProfile(String userName, Node profileNode) throws RepositoryException
{
UserProfile profile = createUserProfileInstance(userName);
PropertyIterator attributes = profileNode.getProperties();
while (attributes.hasNext())
{
Property prop = attributes.nextPropert... | java |
private void writeProfile(UserProfile userProfile, Node profileNode) throws RepositoryException
{
for (Entry<String, String> attribute : userProfile.getUserInfoMap().entrySet())
{
profileNode.setProperty(ATTRIBUTE_PREFIX + attribute.getKey(), attribute.getValue());
}
} | java |
private UserProfile getFromCache(String userName)
{
return (UserProfile)cache.get(userName, CacheType.USER_PROFILE);
} | java |
private void putInCache(UserProfile profile)
{
cache.put(profile.getUserName(), profile, CacheType.USER_PROFILE);
} | java |
private void preSave(UserProfile userProfile, boolean isNew) throws Exception
{
for (UserProfileEventListener listener : listeners)
{
listener.preSave(userProfile, isNew);
}
} | java |
private void postSave(UserProfile userProfile, boolean isNew) throws Exception
{
for (UserProfileEventListener listener : listeners)
{
listener.postSave(userProfile, isNew);
}
} | java |
private void preDelete(UserProfile userProfile, boolean broadcast) throws Exception
{
for (UserProfileEventListener listener : listeners)
{
listener.preDelete(userProfile);
}
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.