下面列出了java.net.URI#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void commandExecution() {
try {
boolean emailExists = false;
URI emailURI = new URI(MAILTO_SCHEME+getParameters().getEmail());
for(URI contact : registrationManagement.getAccount().getContacts()){
if (emailURI.equals(contact)){
emailExists = true;
break;
}
}
if(!emailExists){
registrationManagement.addContact(emailURI);
}
} catch (AcmeException | URISyntaxException e) {
LOG.error("Cannot add email : "+getParameters().getEmail(), e);
error = true;
}
}
private void processCharacters(final Characters chars, final StartElement currentElement, final Map<URI, Policy> map)
throws PolicyException {
if (chars.isWhiteSpace()) {
return;
}
else {
final String data = chars.getData();
if ((currentElement != null) && URI.equals(currentElement.getName())) {
processUri(chars, map);
return;
} else {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0092_CHARACTER_DATA_UNEXPECTED(currentElement, data, chars.getLocation())));
}
}
}
/**
*
* @param path
* non null, full abstract path in the local file system
* @return {@link Status#OK_STATUS} in case that given path might be a valid
* FindBugs detector package (jar file containing bugrank.txt,
* findbugs.xml, messages.xml and at least one class file). Returns
* error status in case anything goes wrong or file at given path is
* not considered as a valid plugin.
*/
@Nonnull
public ValidationStatus validate(String path) {
File file = new File(path);
Summary sum = null;
try {
sum = PluginLoader.validate(file);
} catch (IllegalArgumentException e) {
if (FindbugsPlugin.getDefault().isDebugging()) {
e.printStackTrace();
}
return new ValidationStatus(IStatus.ERROR,
"Invalid SpotBugs plugin archive: " + e.getMessage(), sum, e);
}
Plugin loadedPlugin = Plugin.getByPluginId(sum.id);
URI uri = file.toURI();
if (loadedPlugin != null && !uri.equals(loadedPlugin.getPluginLoader().getURI())
&& loadedPlugin.isGloballyEnabled()) {
return new ValidationStatus(IStatus.ERROR, "Duplicated SpotBugs plugin: " + sum.id + ", already loaded from: "
+ loadedPlugin.getPluginLoader().getURI(), sum, null);
}
return new ValidationStatus(IStatus.OK, Status.OK_STATUS.getMessage(), sum, null);
}
@Override
public ConfigDescription getConfigDescription(URI uri, Locale locale) {
if (uri.equals(createURI("hue:LCT001:color"))) {
ConfigDescriptionParameter paramDefault = new ConfigDescriptionParameter("defaultConfig", Type.TEXT) {
@Override
public String getDefault() {
return "defaultValue";
};
};
ConfigDescriptionParameter paramCustom = new ConfigDescriptionParameter("customConfig", Type.TEXT) {
@Override
public String getDefault() {
return "none";
};
};
return new ConfigDescription(uri, Stream.of(paramDefault, paramCustom).collect(toList()));
}
return null;
}
/**
* Connects web socket client.
*
* @param endpoint The full address of an endpoint to connect to.
* Usually starts with 'ws://'.
*/
public void connect(URI endpoint) {
if (endpoint.equals(this.getEndpoint()) && isListening) {
return;
}
OkHttpClient client = new OkHttpClient.Builder()
.readTimeout(0, TimeUnit.MILLISECONDS)
.build();
Request request = new Request.Builder()
.url(endpoint.toString())
.build();
client.newWebSocket(request, this);
client.dispatcher().executorService().shutdown();
setEndpoint(endpoint);
}
private void processCharacters(final Characters chars, final StartElement currentElement, final Map<URI, Policy> map)
throws PolicyException {
if (chars.isWhiteSpace()) {
return;
}
else {
final String data = chars.getData();
if ((currentElement != null) && URI.equals(currentElement.getName())) {
processUri(chars, map);
return;
} else {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0092_CHARACTER_DATA_UNEXPECTED(currentElement, data, chars.getLocation())));
}
}
}
private void downloadProfilePicture(final String profileId, URI pictureURI, final ImageView imageView) {
if (pictureURI == null) {
return;
}
// If we don't have an imageView, we are pre-fetching this image to store in-memory because we
// think the user might scroll to its corresponding list row. If we do have an imageView, we
// only want to queue a download if the view's tag isn't already set to the URL (which would mean
// it's already got the correct picture).
boolean prefetching = imageView == null;
if (prefetching || !pictureURI.equals(imageView.getTag())) {
if (!prefetching) {
// Setting the tag to the profile ID indicates that we're currently downloading the
// picture for this profile; we'll set it to the actual picture URL when complete.
imageView.setTag(profileId);
imageView.setImageResource(getDefaultPicture());
}
ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureURI)
.setCallerTag(this)
.setCallback(
new ImageRequest.Callback() {
@Override
public void onCompleted(ImageResponse response) {
processImageResponse(response, profileId, imageView);
}
});
ImageRequest newRequest = builder.build();
pendingRequests.put(profileId, newRequest);
ImageDownloader.downloadAsync(newRequest);
}
}
@Override
public List<Proxy> select(URI uri) {
//暂时只支持91porn视频
String url = preferencesHelper.getPorn9VideoAddress();
//如果url为空,直接跳过
if (TextUtils.isEmpty(url)) {
Logger.t(TAG).d("链接为空");
return null;
}
URI uri1 = URI.create(url);
//对比是不是同一链接,是则启用,否则跳过
if (uri1.equals(uri)) {
Logger.t(TAG).d("select(URI uri)-----------------------------::::是相等的,可以启用了");
boolean isOpenProxy = preferencesHelper.isOpenHttpProxy();
if (isTest) {
Logger.t(TAG).d("本次为代理测试了");
return proxyList;
} else {
if (isOpenProxy) {
Logger.t(TAG).d("本次为正式代理");
//如果代理地址不为空,且端口正确设置Http代理
String proxyHost = preferencesHelper.getProxyIpAddress();
int port = preferencesHelper.getProxyPort();
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, port));
proxyList.clear();
proxyList.add(proxy);
} else {
Logger.t(TAG).d("select(URI uri)-----------------------------::::" + uri.toString());
Logger.t(TAG).d("未有任何代理或测试");
return null;
}
}
return proxyList;
}
return null;
}
static void eq0(URI u, URI v) throws URISyntaxException {
testCount++;
if (!u.equals(v))
throw new RuntimeException("Not equal: " + u + " " + v);
int uh = u.hashCode();
int vh = v.hashCode();
if (uh != vh)
throw new RuntimeException("Hash codes not equal: "
+ u + " " + Integer.toHexString(uh) + " "
+ v + " " + Integer.toHexString(vh));
out.println();
out.println(u + " == " + v
+ " [" + Integer.toHexString(uh) + "]");
}
/**
* Test URI -> Path -> URI
*/
static void testUri(String s) throws Exception {
URI uri = URI.create(s);
log.println(uri);
Path path = Paths.get(uri);
log.println(" --> " + path);
URI result = path.toUri();
log.println(" --> " + result);
if (!result.equals(uri)) {
log.println("FAIL: Expected " + uri + ", got " + result);
failures++;
}
log.println();
}
static void ne0(URI u, URI v) throws URISyntaxException {
testCount++;
if (u.equals(v))
throw new RuntimeException("Equal: " + u + " " + v);
out.println();
out.println(u + " != " + v
+ " [" + Integer.toHexString(u.hashCode())
+ " " + Integer.toHexString(v.hashCode())
+ "]");
}
@Test
public void testRemoveURIFromPool() throws URISyntaxException {
FailoverUriPool pool = new FailoverUriPool(uris, null);
pool.setRandomize(false);
URI removed = uris.get(0);
pool.remove(removed);
for (int i = 0; i < uris.size() + 1; ++i) {
if (removed.equals(pool.getNext())) {
fail("URI was not removed from the pool");
}
}
}
static void ne0(URI u, URI v) throws URISyntaxException {
testCount++;
if (u.equals(v))
throw new RuntimeException("Equal: " + u + " " + v);
out.println();
out.println(u + " != " + v
+ " [" + Integer.toHexString(u.hashCode())
+ " " + Integer.toHexString(v.hashCode())
+ "]");
}
public static IConnectionPoint findConnectionPoint(URI uri)
{
for (IConnectionPoint i : CoreIOPlugin.getConnectionPointManager().getConnectionPoints())
{
if (uri.equals(i.getRootURI()))
{
return i;
}
}
return null;
}
private void updateUI() {
if (!isAdded()) {
return;
}
if (isSessionOpen()) {
connectedStateLabel.setTextColor(getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_text_color));
connectedStateLabel.setShadowLayer(1f, 0f, -1f,
getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_shadow_color));
if (user != null) {
ImageRequest request = getImageRequest();
if (request != null) {
URI requestUrl = request.getImageUri();
// Do we already have the right picture? If so, leave it alone.
if (!requestUrl.equals(connectedStateLabel.getTag())) {
if (user.getId().equals(userProfilePicID)) {
connectedStateLabel.setCompoundDrawables(null, userProfilePic, null, null);
connectedStateLabel.setTag(requestUrl);
} else {
ImageDownloader.downloadAsync(request);
}
}
}
connectedStateLabel.setText(user.getName());
} else {
connectedStateLabel.setText(getResources().getString(
R.string.com_facebook_usersettingsfragment_logged_in));
Drawable noProfilePic = getResources().getDrawable(R.drawable.com_facebook_profile_default_icon);
noProfilePic.setBounds(0, 0,
getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height));
connectedStateLabel.setCompoundDrawables(null, noProfilePic, null, null);
}
} else {
int textColor = getResources().getColor(R.color.com_facebook_usersettingsfragment_not_connected_text_color);
connectedStateLabel.setTextColor(textColor);
connectedStateLabel.setShadowLayer(0f, 0f, 0f, textColor);
connectedStateLabel.setText(getResources().getString(
R.string.com_facebook_usersettingsfragment_not_logged_in));
connectedStateLabel.setCompoundDrawables(null, null, null, null);
connectedStateLabel.setTag(null);
}
}
public void joinNodesAndVerifyConvergence(String customGroupPath, int hostCount,
int memberCount,
Map<URI, EnumSet<NodeOption>> expectedOptionsPerNode,
boolean waitForTimeSync) throws Throwable {
// invoke op as system user
setAuthorizationContext(getSystemAuthorizationContext());
if (hostCount == 0) {
return;
}
Map<URI, URI> nodeGroupPerHost = new HashMap<>();
if (customGroupPath != null) {
for (Entry<URI, URI> e : this.peerNodeGroups.entrySet()) {
URI ngUri = UriUtils.buildUri(e.getKey(), customGroupPath);
nodeGroupPerHost.put(e.getKey(), ngUri);
}
} else {
nodeGroupPerHost = this.peerNodeGroups;
}
if (this.isRemotePeerTest()) {
memberCount = getPeerCount();
}
if (!isRemotePeerTest() || (isRemotePeerTest() && this.joinNodes)) {
for (URI initialNodeGroupService : this.peerNodeGroups.values()) {
if (customGroupPath != null) {
initialNodeGroupService = UriUtils.buildUri(initialNodeGroupService,
customGroupPath);
}
for (URI nodeGroup : this.peerNodeGroups.values()) {
if (customGroupPath != null) {
nodeGroup = UriUtils.buildUri(nodeGroup, customGroupPath);
}
if (initialNodeGroupService.equals(nodeGroup)) {
continue;
}
testStart(1);
joinNodeGroup(nodeGroup, initialNodeGroupService, memberCount);
testWait();
}
}
}
// for local or remote tests, we still want to wait for convergence
waitForNodeGroupConvergence(nodeGroupPerHost.values(), memberCount, null,
expectedOptionsPerNode, waitForTimeSync);
waitForNodeGroupIsAvailableConvergence(customGroupPath);
//reset auth context
setAuthorizationContext(null);
}
private Discoverer createDiscoverer(URI uri) {
log.trace("New discoverer for {}", uri);
final Discoverer d = new Discoverer(uri, refreshDelayMs, uri.equals(nodes.uri()));
d.engageNextTimerTick();
return d;
}
private void updateUI() {
if (!isAdded()) {
return;
}
if (isSessionOpen()) {
connectedStateLabel.setTextColor(getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_text_color));
connectedStateLabel.setShadowLayer(1f, 0f, -1f,
getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_shadow_color));
if (user != null) {
ImageRequest request = getImageRequest();
if (request != null) {
URI requestUrl = request.getImageUri();
// Do we already have the right picture? If so, leave it alone.
if (!requestUrl.equals(connectedStateLabel.getTag())) {
if (user.getId().equals(userProfilePicID)) {
connectedStateLabel.setCompoundDrawables(null, userProfilePic, null, null);
connectedStateLabel.setTag(requestUrl);
} else {
ImageDownloader.downloadAsync(request);
}
}
}
connectedStateLabel.setText(user.getName());
} else {
connectedStateLabel.setText(getResources().getString(
R.string.com_facebook_usersettingsfragment_logged_in));
Drawable noProfilePic = getResources().getDrawable(R.drawable.com_facebook_profile_default_icon);
noProfilePic.setBounds(0, 0,
getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height));
connectedStateLabel.setCompoundDrawables(null, noProfilePic, null, null);
}
} else {
int textColor = getResources().getColor(R.color.com_facebook_usersettingsfragment_not_connected_text_color);
connectedStateLabel.setTextColor(textColor);
connectedStateLabel.setShadowLayer(0f, 0f, 0f, textColor);
connectedStateLabel.setText(getResources().getString(
R.string.com_facebook_usersettingsfragment_not_logged_in));
connectedStateLabel.setCompoundDrawables(null, null, null, null);
connectedStateLabel.setTag(null);
}
}
private void updateUI() {
if (!isAdded()) {
return;
}
if (isSessionOpen()) {
connectedStateLabel.setTextColor(getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_text_color));
connectedStateLabel.setShadowLayer(1f, 0f, -1f,
getResources().getColor(R.color.com_facebook_usersettingsfragment_connected_shadow_color));
if (user != null) {
ImageRequest request = getImageRequest();
if (request != null) {
URI requestUrl = request.getImageUri();
// Do we already have the right picture? If so, leave it alone.
if (!requestUrl.equals(connectedStateLabel.getTag())) {
if (user.getId().equals(userProfilePicID)) {
connectedStateLabel.setCompoundDrawables(null, userProfilePic, null, null);
connectedStateLabel.setTag(requestUrl);
} else {
ImageDownloader.downloadAsync(request);
}
}
}
connectedStateLabel.setText(user.getName());
} else {
connectedStateLabel.setText(getResources().getString(
R.string.com_facebook_usersettingsfragment_logged_in));
Drawable noProfilePic = getResources().getDrawable(R.drawable.com_facebook_profile_default_icon);
noProfilePic.setBounds(0, 0,
getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width),
getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height));
connectedStateLabel.setCompoundDrawables(null, noProfilePic, null, null);
}
} else {
int textColor = getResources().getColor(R.color.com_facebook_usersettingsfragment_not_connected_text_color);
connectedStateLabel.setTextColor(textColor);
connectedStateLabel.setShadowLayer(0f, 0f, 0f, textColor);
connectedStateLabel.setText(getResources().getString(
R.string.com_facebook_usersettingsfragment_not_logged_in));
connectedStateLabel.setCompoundDrawables(null, null, null, null);
connectedStateLabel.setTag(null);
}
}
/**
* Checks whether the archive referenced by the package fragment root is not
* shared with multiple java projects in the workspace.
*
* @param root
* the package fragment root
* @param monitor
* the progress monitor to use
* @return the status of the operation
*/
private static RefactoringStatus checkPackageFragmentRoots(final IPackageFragmentRoot root, final IProgressMonitor monitor) {
final RefactoringStatus status= new RefactoringStatus();
try {
monitor.beginTask(JarImportMessages.JarImportWizard_prepare_import, 100);
final IWorkspaceRoot workspace= ResourcesPlugin.getWorkspace().getRoot();
if (workspace != null) {
final IJavaModel model= JavaCore.create(workspace);
if (model != null) {
try {
final URI uri= getLocationURI(root.getRawClasspathEntry());
if (uri != null) {
final IJavaProject[] projects= model.getJavaProjects();
final IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL);
try {
subMonitor.beginTask(JarImportMessages.JarImportWizard_prepare_import, projects.length * 100);
for (int index= 0; index < projects.length; index++) {
final IPackageFragmentRoot[] roots= projects[index].getPackageFragmentRoots();
final IProgressMonitor subsubMonitor= new SubProgressMonitor(subMonitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL);
try {
subsubMonitor.beginTask(JarImportMessages.JarImportWizard_prepare_import, roots.length);
for (int offset= 0; offset < roots.length; offset++) {
final IPackageFragmentRoot current= roots[offset];
if (!current.equals(root) && current.getKind() == IPackageFragmentRoot.K_BINARY) {
final IClasspathEntry entry= current.getRawClasspathEntry();
if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
final URI location= getLocationURI(entry);
if (uri.equals(location))
status.addFatalError(Messages.format(JarImportMessages.JarImportWizard_error_shared_jar, new String[] { JavaElementLabels.getElementLabel(current.getJavaProject(), JavaElementLabels.ALL_DEFAULT) }));
}
}
subsubMonitor.worked(1);
}
} finally {
subsubMonitor.done();
}
}
} finally {
subMonitor.done();
}
}
} catch (CoreException exception) {
status.addError(exception.getLocalizedMessage());
}
}
}
} finally {
monitor.done();
}
return status;
}