Example usage for java.util Set remove

List of usage examples for java.util Set remove

Introduction

In this page you can find the example usage for java.util Set remove.

Prototype

boolean remove(Object o);

Source Link

Document

Removes the specified element from this set if it is present (optional operation).

Usage

From source file:edu.uci.ics.jung.utils.SubsetManager.java

/**
 * Removes the vertex whose event this is from all appropriate subsets.
 *///from   w ww .  j av  a 2  s.  c o  m
public void vertexRemoved(GraphEvent event) {
    ArchetypeVertex v = (ArchetypeVertex) event.getGraphElement();
    Map vMap = getVertexMap();
    for (Iterator iter = vMap.keySet().iterator(); iter.hasNext();) {
        Set s = (Set) vMap.get(iter.next());
        s.remove(v);
    }
}

From source file:edu.uci.ics.jung.utils.SubsetManager.java

/**
 * Removes the edge whose event this is from all appropriate subsets.
 *//*from w w  w  .ja va2s.c  o m*/
public void edgeRemoved(GraphEvent event) {
    ArchetypeEdge e = (ArchetypeEdge) event.getGraphElement();
    Map eMap = getEdgeMap();
    for (Iterator iter = eMap.keySet().iterator(); iter.hasNext();) {
        Set s = (Set) eMap.get(iter.next());
        s.remove(e);
    }
}

From source file:ch.rasc.extclassgenerator.ModelGenerator.java

public static String generateJavascript(ModelBean model, OutputConfig outputConfig) {

    if (!outputConfig.isDebug()) {
        JsCacheKey key = new JsCacheKey(model, outputConfig);

        SoftReference<String> jsReference = jsCache.get(key);
        if (jsReference != null && jsReference.get() != null) {
            return jsReference.get();
        }//w ww. j  a va  2 s  .  c o m
    }

    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, false);

    if (!outputConfig.isSurroundApiWithQuotes()) {
        if (outputConfig.getOutputFormat() == OutputFormat.EXTJS5) {
            mapper.addMixInAnnotations(ProxyObject.class, ProxyObjectWithoutApiQuotesExtJs5Mixin.class);
        } else {
            mapper.addMixInAnnotations(ProxyObject.class, ProxyObjectWithoutApiQuotesMixin.class);
        }
        mapper.addMixInAnnotations(ApiObject.class, ApiObjectMixin.class);
    } else {
        if (outputConfig.getOutputFormat() != OutputFormat.EXTJS5) {
            mapper.addMixInAnnotations(ProxyObject.class, ProxyObjectWithApiQuotesMixin.class);
        }
    }

    Map<String, Object> modelObject = new LinkedHashMap<String, Object>();
    modelObject.put("extend", model.getExtend());

    if (!model.getAssociations().isEmpty()) {
        Set<String> usesClasses = new HashSet<String>();
        for (AbstractAssociation association : model.getAssociations()) {
            usesClasses.add(association.getModel());
        }

        usesClasses.remove(model.getName());

        if (!usesClasses.isEmpty()) {
            modelObject.put("uses", usesClasses);
        }
    }

    Map<String, Object> configObject = new LinkedHashMap<String, Object>();
    ProxyObject proxyObject = new ProxyObject(model, outputConfig);

    Map<String, ModelFieldBean> fields = model.getFields();
    Set<String> requires = new HashSet<String>();

    if (!model.getValidations().isEmpty() && outputConfig.getOutputFormat() == OutputFormat.EXTJS5) {
        requires = addValidatorsToField(fields, model.getValidations());
    }

    if (proxyObject.hasContent() && outputConfig.getOutputFormat() == OutputFormat.EXTJS5) {
        requires.add("Ext.data.proxy.Direct");
    }

    if (StringUtils.hasText(model.getIdentifier()) && outputConfig.getOutputFormat() == OutputFormat.EXTJS5) {
        if ("sequential".equals(model.getIdentifier())) {
            requires.add("Ext.data.identifier.Sequential");
        } else if ("uuid".equals(model.getIdentifier())) {
            requires.add("Ext.data.identifier.Uuid");
        } else if ("negative".equals(model.getIdentifier())) {
            requires.add("Ext.data.identifier.Negative");
        }
    }

    if (requires != null && !requires.isEmpty()) {
        configObject.put("requires", requires);
    }

    if (StringUtils.hasText(model.getIdentifier())) {
        if (outputConfig.getOutputFormat() == OutputFormat.EXTJS5
                || outputConfig.getOutputFormat() == OutputFormat.TOUCH2) {
            configObject.put("identifier", model.getIdentifier());
        } else {
            configObject.put("idgen", model.getIdentifier());
        }
    }

    if (StringUtils.hasText(model.getIdProperty()) && !model.getIdProperty().equals("id")) {
        configObject.put("idProperty", model.getIdProperty());
    }

    if (outputConfig.getOutputFormat() == OutputFormat.EXTJS5
            && StringUtils.hasText(model.getVersionProperty())) {
        configObject.put("versionProperty", model.getVersionProperty());
    }

    if (StringUtils.hasText(model.getClientIdProperty())) {

        if (outputConfig.getOutputFormat() == OutputFormat.EXTJS5
                || outputConfig.getOutputFormat() == OutputFormat.EXTJS4) {
            configObject.put("clientIdProperty", model.getClientIdProperty());
        } else if (outputConfig.getOutputFormat() == OutputFormat.TOUCH2
                && !"clientId".equals(model.getClientIdProperty())) {
            configObject.put("clientIdProperty", model.getClientIdProperty());
        }
    }

    for (ModelFieldBean field : fields.values()) {
        field.updateTypes(outputConfig);
    }

    List<Object> fieldConfigObjects = new ArrayList<Object>();
    for (ModelFieldBean field : fields.values()) {
        if (field.hasOnlyName(outputConfig)) {
            fieldConfigObjects.add(field.getName());
        } else {
            fieldConfigObjects.add(field);
        }
    }
    configObject.put("fields", fieldConfigObjects);

    if (!model.getAssociations().isEmpty()) {
        configObject.put("associations", model.getAssociations());
    }

    if (!model.getValidations().isEmpty() && !(outputConfig.getOutputFormat() == OutputFormat.EXTJS5)) {
        configObject.put("validations", model.getValidations());
    }

    if (proxyObject.hasContent()) {
        configObject.put("proxy", proxyObject);
    }

    if (outputConfig.getOutputFormat() == OutputFormat.EXTJS4
            || outputConfig.getOutputFormat() == OutputFormat.EXTJS5) {
        modelObject.putAll(configObject);
    } else {
        modelObject.put("config", configObject);
    }

    StringBuilder sb = new StringBuilder();
    sb.append("Ext.define(\"").append(model.getName()).append("\",");
    if (outputConfig.isDebug()) {
        sb.append("\n");
    }

    String configObjectString;
    Class<?> jsonView = JsonViews.ExtJS4.class;
    if (outputConfig.getOutputFormat() == OutputFormat.TOUCH2) {
        jsonView = JsonViews.Touch2.class;
    } else if (outputConfig.getOutputFormat() == OutputFormat.EXTJS5) {
        jsonView = JsonViews.ExtJS5.class;
    }

    try {
        if (outputConfig.isDebug()) {
            configObjectString = mapper.writerWithDefaultPrettyPrinter().withView(jsonView)
                    .writeValueAsString(modelObject);
        } else {
            configObjectString = mapper.writerWithView(jsonView).writeValueAsString(modelObject);
        }

    } catch (JsonGenerationException e) {
        throw new RuntimeException(e);
    } catch (JsonMappingException e) {
        throw new RuntimeException(e);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    sb.append(configObjectString);
    sb.append(");");

    String result = sb.toString();

    if (outputConfig.isUseSingleQuotes()) {
        result = result.replace('"', '\'');
    }

    if (!outputConfig.isDebug()) {
        jsCache.put(new JsCacheKey(model, outputConfig), new SoftReference<String>(result));
    }
    return result;
}

From source file:com.redhat.rhn.frontend.action.user.UserPrefAction.java

private void handlePanes(DynaActionForm form, User user) {
    Map allPanes = PaneFactory.getAllPanes();

    String[] selections = (String[]) form.get("selectedPanes");
    Set hiddenPanes = new HashSet(allPanes.values());

    if (selections != null) {
        for (int i = 0; i < selections.length; i++) {
            hiddenPanes.remove(allPanes.get(selections[i]));
        }//from w ww.  j  a  va2s .co  m
    }
    user.setHiddenPanes(hiddenPanes);
}

From source file:com.sshdemo.common.report.manage.service.TextReportService.java

@Override
public Long updTextReportParameter(Long textReportId, Parameter parameter) throws BaseException {
    if (textReportId == null || textReportId.intValue() == 0)
        throw new BaseException("", "????");
    TextReport text = textReportDAO.get(textReportId);
    if (text == null)
        throw new BaseException("", "???");

    parameter = ParameterSetValueUtil.setParametersValue(parameter);

    Set<Parameter> parameters = text.getParameters();
    parameters.remove(parameter);
    parameters.add(parameter);/*from ww  w . j  av  a 2 s  .  c om*/
    text.setParameters(parameters);

    textReportDAO.merge(text);

    return parameter.getId();
}

From source file:com.eucalyptus.auth.login.Hmacv1LoginModule.java

private String makeSubjectString(final Map<String, List<String>> parameters)
        throws UnsupportedEncodingException {
    String paramString = "";
    Set<String> sortedKeys = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
    sortedKeys.addAll(parameters.keySet());
    sortedKeys.remove(SecurityParameter.Signature.parameter());
    for (final String key : sortedKeys) {
        if (parameters.get(key).isEmpty()) {
            paramString = paramString.concat(key).replaceAll("\\+", " ");
        } else//  w  ww  . j  av  a 2  s.  com
            for (final String value : Ordering.natural().sortedCopy(parameters.get(key))) {
                paramString = paramString.concat(key).concat(Strings.nullToEmpty(value).replaceAll("\\+", " "));
            }
    }
    try {
        return new String(URLCodec.decodeUrl(paramString.getBytes()));
    } catch (DecoderException e) {
        return paramString;
    }
}

From source file:org.apache.syncope.core.propagation.LDAPDomainPropagationActions.java

@Override
public void before(PropagationTask pt, ConnectorObject co) {

    // Get ConnInstance object to retrieve Configuration of current connector
    ConnInstance connInstance = pt.getResource().getConnector();
    String baseContextUser = null;
    StringBuilder sb = new StringBuilder();
    // Search of connector property containing base context(s)
    for (ConnConfProperty property : connInstance.getConfiguration()) {
        if ("baseContexts".equals(property.getSchema().getName())) {
            baseContextUser = (String) property.getValues().get(0);
        }//from ww w .jav  a2s.  c  o  m
    }
    if (!(ResourceOperation.DELETE == pt.getPropagationOperation())
            && ObjectClass.ACCOUNT_NAME.equals(pt.getObjectClassName())) {
        // Selection of current user to CREATE/UPDATE
        SyncopeUser user = userDAO.find(pt.getSubjectId());
        Attribute newAccountLink;
        if (user != null) {
            String domain = user.getAttribute("domain").getValuesAsStrings().iterator().next();
            if (domain != null) {
                String dn;
                if (!"/".equals(domain)) {
                    sb.append("uid=").append(user.getUsername()).append(",ou=").append(domain).append(",")
                            .append(baseContextUser);
                    dn = sb.toString();
                } else {
                    sb.append("uid=").append(user.getUsername()).append(",").append(baseContextUser);
                    dn = sb.toString();
                }
                newAccountLink = AttributeBuilder.build(Name.NAME, dn);
                LOG.debug("NEW ACCOUNTLINK: " + newAccountLink.getValue());
                //Get task attributes
                Set<Attribute> newAttributes = pt.getAttributes();
                //Remove old account link from task attributes
                boolean removeResult = newAttributes.remove(AttributeUtil.find(Name.NAME, pt.getAttributes()));
                LOG.debug("DELETE OLD ACCOUNT LINK: " + removeResult);
                //Add new attributes with new Account Link set
                boolean addResult = newAttributes.add(newAccountLink);
                LOG.debug("ADD NEW ACCOUNT LINK: " + addResult);
                pt.setAttributes(newAttributes);
            } else {
                LOG.debug("DOMAIN IN NULL");
            }
        }
    }
}

From source file:org.atemsource.atem.utility.observer.EntityObserver.java

public void unwatch(AttributePath path, Object listener) {

    if (listener instanceof SingleAttributeListener) {
        Set<SingleAttributeListener> attributeListeners = listeners.get(path);
        if (attributeListeners != null) {
            attributeListeners.remove(listener);
        }/*from  ww  w .j  a  va2s. c  o m*/
    } else {
        attributeListeners.remove(listener);
    }
}

From source file:dk.microting.softkeyboard.autoupdateapk.AutoUpdateApk.java

private static boolean haveInternetPermissions() {
    Set<String> required_perms = new HashSet<String>();
    required_perms.add("android.permission.INTERNET");
    required_perms.add("android.permission.ACCESS_WIFI_STATE");
    required_perms.add("android.permission.ACCESS_NETWORK_STATE");

    PackageManager pm = context.getPackageManager();
    String packageName = context.getPackageName();
    int flags = PackageManager.GET_PERMISSIONS;
    PackageInfo packageInfo = null;//from w ww.j  a  va 2 s. com

    try {
        packageInfo = pm.getPackageInfo(packageName, flags);
        versionCode = packageInfo.versionCode;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    if (packageInfo.requestedPermissions != null) {
        for (String p : packageInfo.requestedPermissions) {
            //Log.v(TAG, "permission: " + p.toString());
            required_perms.remove(p);
        }
        if (required_perms.size() == 0) {
            return true; // permissions are in order
        }
        // something is missing
        for (String p : required_perms) {
            Log.e(TAG, "required permission missing: " + p);
        }
    }
    Log.e(TAG, "INTERNET/WIFI access required, but no permissions are found in Manifest.xml");
    return false;
}

From source file:com.espertech.esper.core.StatementEventTypeRefImpl.java

private void removeReference(String statementName, String eventTypeName) {
    // remove from types
    Set<String> statements = typeToStmt.get(eventTypeName);
    if (statements != null) {
        if (!statements.remove(statementName)) {
            log.info("Failed to find statement name '" + statementName + "' in collection");
        }/*from  www .  j  a  v a 2 s  . com*/

        if (statements.isEmpty()) {
            typeToStmt.remove(eventTypeName);
        }
    }

    // remove from statements
    Set<String> types = stmtToType.get(statementName);
    if (types != null) {
        if (!types.remove(eventTypeName)) {
            log.info("Failed to find event type '" + eventTypeName + "' in collection");
        }

        if (types.isEmpty()) {
            stmtToType.remove(statementName);
        }
    }
}