Normalizes the state string. Ensuring it starts with the right number of slashes resolving an issue with the vaadin state handling.<p>

@param state the state string

@return the normalized state string
979093
private String normalizeState(String state) {

        String result = "";
        if (state.contains(STATE_SEPARATOR)) {
            result = state;
            while (result.startsWith("/")) {
                result = result.substring(1);
            }
        }
        return result;
    }
1293316
public static String from(int state) {
        switch (state) {
            case Bundle.ACTIVE:
                return ACTIVE;
            case Bundle.INSTALLED:
                return INSTALLED;
            case Bundle.RESOLVED:
                return RESOLVED;
            case Bundle.STARTING:
                return STARTING;
            case Bundle.STOPPING:
                return STOPPING;
            case Bundle.UNINSTALLED:
                return UNINSTALLED;
            default:
                return "UNKNOWN (" + Integer.toString(state) + ")";
        }
    }
849204
public static StateObj state(StateObj... states) {
        MutableStateObj mutable = mutable();
        for (StateObj state : states) {
            mutable.updateState(state);
        }
        return state(mutable.getState());
    }
1284388
public static String normalize(String val) {
        if (val == null || val.trim().length() == 0) return null;
        return val.trim();
    }
1136919
public String getStateAsString(){
		Integer state = getState();
		if (STOPPED.equals(state)){
			return "Stopped";
		}
		if (STARTING.equals(state)){
			return "Starting";
		}
		if (RUNNING.equals(state)){
			return "Running";
		}
		if (STOPPING.equals(state)){
			return "Stopping";
		}
		throw new IllegalStateException("Unknown state: " + state);
	}
1104988
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());
  }
799953
private String stateToString(long s) {
        return super.toString() +
            "[phase = " + phaseOf(s) +
            " parties = " + partiesOf(s) +
            " arrived = " + arrivedOf(s) + "]";
    }
267015
public static CmsResourceState valueOf(int state) {

        switch (state) {
            case 0:
                return CmsResource.STATE_UNCHANGED;
            case 1:
                return CmsResource.STATE_CHANGED;
            case 2:
                return CmsResource.STATE_NEW;
            case 3:
                return CmsResource.STATE_DELETED;
            case 99:
            default:
                return CmsResource.STATE_KEEP;
        }
    }
247201
private String escape(final String string, final State inState) {
        if (string == null) { return null; }
        State state = inState;
        final int length = string.length();
        for (int index = 0; index < length; index++) {
            /* We don't do anything with the protocol separator */
            if (state == State.HOST && string.indexOf(PROTOCOL_SEPARATOR) == index) {
                index += PROTOCOL_SEPARATOR.length();
                continue;
            }
            final char c = string.charAt(index);
            if (HOST_SEPARATOR.matches(c) && state == State.HOST) {
                state = State.PATH;
            }
            if (FRAG_SEPARATOR.matches(c) && state != State.FRAGMENT && state != State.QUERY_PARAM) {
                /* Switch state - don't do anything with this character */
                state = State.FRAGMENT;
            } else if (QUERY_SEPARATOR.matches(c) && (state == State.PATH || state == State.HOST)) {
                /* Switch state - don't do anything with this character */
                state = State.QUERY;
            } else {
                final String encodeString = encodeCharAtIndex(string, index, state);
                if (encodeString != null) {
                    /* We are supposed to encode this character - recursively call for the remainder of the string */
                    return string.substring(0, index) + encodeString + escape(string.substring(index + 1), state);
                }
            }
        }
        return string;
    }
1179894
public void setState(State state) {
    this.state = state;
    setText(state.isPrimary() ? text1 : text2);
  }
416709
public static Integer str2state(String str)
    {
        Integer state;

        if (str == null)
        {
            return null;
        }

        state = inverseStateMap.get(str);

        if (state == null)
        {
            Matcher matcher = UNKNOWN_STATE_PATTERN.matcher(str);
            if (matcher.matches())
            {
                try
                {
                    state = Integer.valueOf(matcher.group(1));
                }
                catch (NumberFormatException e)
                {
                    // should not happen as the pattern requires \d+ for the state.
                    throw new IllegalArgumentException("Unable to convert state '" + str + "' to integer representation", e);
                }
            }
        }

        return state;
    }
1009523
public PactDslWithState given(String state) {
        return new PactDslWithState(consumerPactBuilder, consumerPactBuilder.getConsumerName(), providerName,
          new ProviderState(state), defaultRequestValues, defaultResponseValues);
    }
555573
public static String normalizeURI( String uri )
    {
        //
        // If it's a relative URI, normalize it.  Note that we don't want to create a URI
        // (very expensive) unless we think we'll need to.  "./" catches "../" and "./".
        //
        if ( uri.indexOf( "./" ) != -1 )
        {
            try
            {
                uri = new URI( uri ).normalize().toString();
            }
            catch ( URISyntaxException e )
            {
                logger.error( "Could not parse relative URI " + uri );
            }
        }
        
        return uri;
    }
1329476
public static String getStateStyle(CmsResourceState state) {

        if (state.equals(CmsResourceState.STATE_NEW)) {
            return CSS.stateNew();
        } else if (state.equals(CmsResourceState.STATE_DELETED)) {
            return CSS.stateDeleted();
        } else if (state.equals(CmsResourceState.STATE_CHANGED)) {
            return CSS.stateChanged();
        }
        return CSS.noState();
    }
243822
private String normalize(final String viewName) {
		String normalized = viewName;

		if (normalized.startsWith("/")) {
			normalized = normalized.substring(0);
		}

		if (normalized.endsWith("/")) {
			normalized = normalized.substring(0, normalized.length() - 1);
		}

		return normalized.replaceAll("/", ".");
	}
80140
public static int from(String state) {
        switch (state.toUpperCase()) {
            case ACTIVE:
                return Bundle.ACTIVE;
            case INSTALLED:
                return Bundle.INSTALLED;
            case RESOLVED:
                return Bundle.RESOLVED;
            case STARTING:
                return Bundle.STARTING;
            case STOPPING:
                return Bundle.STOPPING;
            case UNINSTALLED:
                return Bundle.UNINSTALLED;
            default:
                return -1; // Unknown.
        }
    }
195436
public static String normalize(final CharSequence self) {
        final String s = self.toString();
        int nx = s.indexOf('\r');

        if (nx < 0) {
            return s;
        }

        final int len = s.length();
        final StringBuilder sb = new StringBuilder(len);

        int i = 0;

        do {
            sb.append(s, i, nx);
            sb.append('\n');

            if ((i = nx + 1) >= len) break;

            if (s.charAt(i) == '\n') {
                // skip the LF in CR LF
                if (++i >= len) break;
            }

            nx = s.indexOf('\r', i);
        } while (nx > 0);

        sb.append(s, i, len);

        return sb.toString();
    }