Java Code Examples for java.lang.String#equals()

The following examples show how to use java.lang.String#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Marshalling.java    From proxymusic with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Indentation before start tag. Always indent.
 *
 * @param localName the local tag name
 * @throws XMLStreamException
 */
private void indentStart (String localName)
        throws XMLStreamException
{
    if (INDENT != null) {
        // Insert visible comment lines only for measures and parts
        if (localName.equals("measure")) {
            doIndent();
            super.writeComment("=======================================================");
        } else if (localName.equals("part")) {
            doIndent();
            super.writeComment("= = = = = = = = = = = = = = = = = = = = = = = = = = = = =");
        }

        doIndent();
        level++;
        closing = false;
    }
}
 
Example 2
Source File: SimpleXmlElement.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public List<SimpleXmlElement> getChildren(@Nonnull String tagName) {
  if (myChildren.isEmpty()) {
    return Collections.emptyList();
  }

  List<SimpleXmlElement> list = new ArrayList<SimpleXmlElement>();
  //noinspection ForLoopReplaceableByForEach
  for (int i = 0; i < myChildren.size(); i++) {
    SimpleXmlElement element = myChildren.get(i);

    if (tagName.equals(element.getName())) {
      list.add(element);
    }
  }
  return list;
}
 
Example 3
Source File: SimpleXmlElement.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public SimpleXmlElement getChild(@Nonnull String tagName) {
  if (myChildren.isEmpty()) {
    return null;
  }

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0; i < myChildren.size(); i++) {
    SimpleXmlElement element = myChildren.get(i);

    if (tagName.equals(element.getName())) {
      return element;
    }
  }
  return null;
}
 
Example 4
Source File: XMLFactoryHelper.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static Object instantiateXMLService(String serviceName) throws Exception {
    ClassLoader backup = Thread.currentThread().getContextClassLoader();
    try {
        // set thread context class loader to module class loader
        Thread.currentThread().setContextClassLoader(XMLFactoryHelper.class.getClassLoader());
        if (serviceName.equals("org.xml.sax.XMLReader"))
            return XMLReaderFactory.createXMLReader();
        else if (serviceName.equals("javax.xml.validation.SchemaFactory"))
            return Class.forName(serviceName).getMethod("newInstance", String.class)
                    .invoke(null, W3C_XML_SCHEMA_NS_URI);
        else
            return Class.forName(serviceName).getMethod("newInstance").invoke(null);
    } finally {
        Thread.currentThread().setContextClassLoader(backup);
    }

}
 
Example 5
Source File: PageFlowController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Remove all rules and cases with this pagename.
 * @param displayName
 */
public void removePageInModel(String displayName) {
    configModel.startTransaction();
    FacesConfig facesConfig = configModel.getRootComponent();
    List<NavigationRule> navRules = facesConfig.getNavigationRules();
    for (NavigationRule navRule : navRules) {
        String fromViewId = FacesModelUtility.getFromViewIdFiltered(navRule);
        if (fromViewId != null && fromViewId.equals(displayName)) {
            //if the rule is removed, don't check the cases.
            facesConfig.removeNavigationRule(navRule);
        } else {
            List<NavigationCase> navCases = navRule.getNavigationCases();
            for (NavigationCase navCase : navCases) {
                //                    String toViewId = navCase.getToViewId();
                String toViewId = FacesModelUtility.getToViewIdFiltered(navCase);
                if (toViewId != null && toViewId.equals(displayName)) {
                    navRule.removeNavigationCase(navCase);
                }
            }
        }
    }

    try {
        configModel.endTransaction();
        configModel.sync();
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    } catch (IllegalStateException ise) {
        Exceptions.printStackTrace(ise);
    }
}
 
Example 6
Source File: FormParameter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void toggleCheckbox( String value ) {
    FormControl[] controls = getControls();
    for (int i = 0; i < controls.length; i++) {
        FormControl control = controls[i];
        if (value.equals( control.getValueAttribute())) {
            control.toggle();
            return;
        }
    }
    throw new IllegalCheckboxParameterException( _name + "/" + value , "toggleCheckbox" );
}
 
Example 7
Source File: FormParameter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void setValue( String value, boolean state ) {
    FormControl[] controls = getControls();
    for (int i = 0; i < controls.length; i++) {
        FormControl control = controls[i];
        if (value.equals( control.getValueAttribute())) {
            control.setState( state );
            return;
        }
    }
    throw new IllegalCheckboxParameterException( _name + "/" + value , "setCheckbox" );
}
 
Example 8
Source File: PageFlowController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Givena pageName, look through the list of predefined webFiles and return the matching fileObject
 * @return FileObject for which the match was found or null of none was found.
 **/
private FileObject getFileObject(String pageName) {
    for (FileObject webFile : webFiles) {
        //DISPLAYNAME:
        String webFileName = Page.getFolderDisplayName(getWebFolder(), webFile);
        //            String webFileName = webFile.getNameExt();
        if (webFileName.equals(pageName)) {
            return webFile;
        }
    }
    return null;
}
 
Example 9
Source File: NetCache.java    From tysq-android with GNU General Public License v3.0 5 votes vote down vote up
public static void refresh() {
    synchronized (Net.class) {
        String json = AppCache.getInstance().getString(SP_NAME);
        if (json == null || json.equals("")) {
            instance = null;
        } else {
            instance = (Net) mGson.fromJson(json, Net.class);
        }
    }
}
 
Example 10
Source File: FieldSetRepo.java    From vespa with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
FieldSet parseSpecialValues(String name)
{
    if (name.equals("[id]")) { return new DocIdOnly(); }
    else if (name.equals("[all]")) { return (new AllFields()); }
    else if (name.equals("[none]")) { return (new NoFields()); }
    else if (name.equals("[header]")) { return (new HeaderFields()); }
    else if (name.equals("[docid]")) { return (new DocIdOnly()); }
    else if (name.equals("[body]")) { return (new BodyFields()); }
    else {
        throw new IllegalArgumentException(
                "The only special names (enclosed in '[]') allowed are " +
                "id, all, none, header, body");
    }
}
 
Example 11
Source File: AsyncPrettyPrintResponseBodyTest.java    From stetho with MIT License 5 votes vote down vote up
@Override
@Nullable
protected MatchResult matchAndParseHeader(String headerName, String headerValue) {
  if (headerName.equals(TEST_HEADER_NAME) && headerValue.equals(TEST_HEADER_VALUE)) {
    return new MatchResult("https://www.facebook.com", PrettyPrinterDisplayType.TEXT);
  } else {
    return null;
  }
}
 
Example 12
Source File: UserManagerAction.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected String getCacheKey(HttpServletRequest req, HttpMethod method, String action) {
    // caching is possible only for userlist and viewuser
    String editAction=req.getParameter("editAction");
    if(editAction==null) editAction="userlist";
    if(!editAction.equals("viewuser") && !editAction.equals("userlist")) return null;
    else return super.getCacheKey(req, method, action);
}
 
Example 13
Source File: PageFlowController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Check if the file type in known.
 * @param file the fileobject type to check. If null, throws NPE.
 * @return if it is of type jsp, jspf, or html it will return true.
 */
public final boolean isKnownFile(FileObject file) {
    String[] knownMimeTypes = {"text/x-jsp", "text/html", "text/xhtml"}; //NOI18N
    String mimeType = file.getMIMEType(knownMimeTypes);
    if (mimeType.equals("text/x-jsp") && !file.getExt().equals("jspf")) { //NOI18N
        return true;
    } else if (mimeType.equals("text/html") || mimeType.equals("text/xhtml")) { //NOI18N
        return true;
    }
    return false;
}
 
Example 14
Source File: PageFlowController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * @return the navigation rule.  This will be null if none was found
 **/
private NavigationRule getRuleWithFromViewID(FacesConfig facesConfig, String fromViewId) {

    for (NavigationRule navRule : facesConfig.getNavigationRules()) {
        String rulefromViewId = FacesModelUtility.getFromViewIdFiltered(navRule);
        if (rulefromViewId != null && rulefromViewId.equals(fromViewId)) {
            //  Match Found
            return navRule;
        }
    }

    return null;
}
 
Example 15
Source File: SQLiteUtils.java    From clear-todolist with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public static String createColumnDefinition(TableInfo tableInfo, Field field) {
	StringBuilder definition = new StringBuilder();

	Class<?> type = field.getType();
	final String name = tableInfo.getColumnName(field);
	final TypeSerializer typeSerializer = Cache.getParserForType(field.getType());
	final Column column = field.getAnnotation(Column.class);

	if (typeSerializer != null) {
		type = typeSerializer.getSerializedType();
	}

	if (TYPE_MAP.containsKey(type)) {
		definition.append(name);
		definition.append(" ");
		definition.append(TYPE_MAP.get(type).toString());
	}
	else if (ReflectionUtils.isModel(type)) {
		definition.append(name);
		definition.append(" ");
		definition.append(SQLiteType.INTEGER.toString());
	}
	else if (ReflectionUtils.isSubclassOf(type, Enum.class)) {
		definition.append(name);
		definition.append(" ");
		definition.append(SQLiteType.TEXT.toString());
	}

	if (!TextUtils.isEmpty(definition)) {

		if (name.equals(tableInfo.getIdName())) {
			definition.append(" PRIMARY KEY AUTOINCREMENT");
		}else if(column!=null){
			if (column.length() > -1) {
				definition.append("(");
				definition.append(column.length());
				definition.append(")");
			}

			if (column.notNull()) {
				definition.append(" NOT NULL ON CONFLICT ");
				definition.append(column.onNullConflict().toString());
			}

			if (column.unique()) {
				definition.append(" UNIQUE ON CONFLICT ");
				definition.append(column.onUniqueConflict().toString());
			}
		}

		if (FOREIGN_KEYS_SUPPORTED && ReflectionUtils.isModel(type)) {
			definition.append(" REFERENCES ");
			definition.append(Cache.getTableInfo((Class<? extends Model>) type).getTableName());
			definition.append("("+tableInfo.getIdName()+")");
			definition.append(" ON DELETE ");
			definition.append(column.onDelete().toString().replace("_", " "));
			definition.append(" ON UPDATE ");
			definition.append(column.onUpdate().toString().replace("_", " "));
		}
	}
	else {
		Log.e("No type mapping for: " + type.toString());
	}

	return definition.toString();
}
 
Example 16
Source File: SQLiteUtils.java    From mobile-android-survey-app with MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public static String createColumnDefinition(TableInfo tableInfo, Field field) {
	StringBuilder definition = new StringBuilder();

	Class<?> type = field.getType();
	final String name = tableInfo.getColumnName(field);
	final TypeSerializer typeSerializer = Cache.getParserForType(field.getType());
	final Column column = field.getAnnotation(Column.class);

	if (typeSerializer != null) {
		type = typeSerializer.getSerializedType();
	}

	if (TYPE_MAP.containsKey(type)) {
		definition.append(name);
		definition.append(" ");
		definition.append(TYPE_MAP.get(type).toString());
	}
	else if (ReflectionUtils.isModel(type)) {
		definition.append(name);
		definition.append(" ");
		definition.append(SQLiteType.INTEGER.toString());
	}
	else if (ReflectionUtils.isSubclassOf(type, Enum.class)) {
		definition.append(name);
		definition.append(" ");
		definition.append(SQLiteType.TEXT.toString());
	}

	if (!TextUtils.isEmpty(definition)) {

		if (name.equals(tableInfo.getIdName())) {
			definition.append(" PRIMARY KEY AUTOINCREMENT");
		}else if(column!=null){
			if (column.length() > -1) {
				definition.append("(");
				definition.append(column.length());
				definition.append(")");
			}

			if (column.notNull()) {
				definition.append(" NOT NULL ON CONFLICT ");
				definition.append(column.onNullConflict().toString());
			}

			if (column.unique()) {
				definition.append(" UNIQUE ON CONFLICT ");
				definition.append(column.onUniqueConflict().toString());
			}
		}

		if (FOREIGN_KEYS_SUPPORTED && ReflectionUtils.isModel(type)) {
			definition.append(" REFERENCES ");
			definition.append(Cache.getTableInfo((Class<? extends Model>) type).getTableName());
			definition.append("("+tableInfo.getIdName()+")");
			definition.append(" ON DELETE ");
			definition.append(column.onDelete().toString().replace("_", " "));
			definition.append(" ON UPDATE ");
			definition.append(column.onUpdate().toString().replace("_", " "));
		}
	}
	else {
		Log.e("No type mapping for: " + type.toString());
	}

	return definition.toString();
}
 
Example 17
Source File: UserManagerAction.java    From wandora with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected HashMap<String, Object> getTemplateContext(Template template, HttpServletRequest req, HttpMethod method, String action, User user) throws ActionException {
    String editAction=req.getParameter("editaction");
    if(editAction==null || editAction.length()==0) editAction="userlist";
    
    HashMap<String,Object> params=super.getTemplateContext(template, req, method, action, user);
    
    String userName=req.getParameter("user");
    if(userName!=null) userName=userName.trim();
    if(userName!=null && userName.length()==0) userName=null;
    
    User userObject=null;
    String view="userlist";
    String error=null;
    try{
        if(editAction.equals("userlist")){
            // no side effects, do nothing
        }
        else if(editAction.equals("viewuser")){
            view="user";
            // just check that the user is valid
            if(userName!=null) userObject=userStore.getUser(userName);
        }
        else if(editAction.equals("edituser") || editAction.equals("edituserlist")){
            view="user";
            if(editAction.equals("edituserlist")) view="userlist";

            if(userName!=null) {
                userObject=userStore.getUser(userName);
                if(userObject!=null){

                    Enumeration<String> paramNames=req.getParameterNames();
                    while(paramNames.hasMoreElements()){
                        String key=paramNames.nextElement();
                        String[] values=req.getParameterValues(key);
                        for(String value : values){
                            value=value.trim();
                            if(key.equals("setoption")){
                                int ind=value.indexOf("=");
                                if(ind<0) userObject.setOption(value, "");
                                else {
                                    String k=value.substring(0,ind);
                                    String v=value.substring(ind+1);
                                    userObject.setOption(k,v);
                                }
                            }
                            else if(key.equals("removeoption")){
                                userObject.removeOption(value);
                            }
                            else if(key.equals("addrole")){
                                userObject.addRole(value);
                            }
                            else if(key.equals("removerole")){
                                userObject.removeRole(value);
                            }
                        }
                    }
                    if(!userObject.saveUser()) error="NOEDIT";
                }
            }
        }
        else if(editAction.equals("deleteuser")){
            if(userName!=null) {
                if(!userStore.deleteUser(userName)) error="NODELETE";
            }
        }
        else if(editAction.equals("newuser")){
            view="user";
            if(userName!=null) {
                userObject=userStore.newUser(userName);
                if(userObject==null) error="NONEW";
            }
        }
        else return null;
        
        if(view.equals("user") && userObject==null) {
            if(error==null) error="INVALIDUSER";
            view="userlist";
        }

        if(view.equals("userlist")){
            params.put("allUsers",userStore.getAllUsers());
        }
        else {
            params.put("user",userObject);
        }
        
    }catch(UserStoreException use){
        if(error==null) error="USERSTORE";
    }
            
    params.put("editView",view);
    params.put("error",error);
    
    return params;
}