Example usage for java.lang CharSequence toString

List of usage examples for java.lang CharSequence toString

Introduction

In this page you can find the example usage for java.lang CharSequence toString.

Prototype

public String toString();

Source Link

Document

Returns a string containing the characters in this sequence in the same order as this sequence.

Usage

From source file:org.callimachusproject.rewrite.RewriteAdvice.java

private String substitute(String uri, Map<String, String> variables) {
    if (replacers == null || replacers.length <= 0)
        return null;
    for (Substitution pattern : replacers) {
        CharSequence result = pattern.replace(uri, variables);
        if (result != null)
            return result.toString();
    }/*from  w w w.  j  a  v  a  2  s .  c o  m*/
    return null;
}

From source file:ch.fixme.status.Widget_config.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.widget_config);
    mPrefs = PreferenceManager.getDefaultSharedPreferences(Widget_config.this);
    getDirTask = new GetDirTask();
    getDirTask.execute(ParseGeneric.API_DIRECTORY);
    Intent intent = getIntent();/*from   w  ww .  jav  a 2 s.  c om*/
    Bundle extras = intent.getExtras();
    mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    findViewById(R.id.choose_ok).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Editor edit = mPrefs.edit();
            edit.putBoolean(Prefs.KEY_WIDGET_TRANSPARENCY,
                    ((CheckBox) findViewById(R.id.choose_transparency)).isChecked());
            edit.commit();
            setWidgetAlarm();
            finish();
        }
    });
    ((CheckBox) findViewById(R.id.choose_transparency))
            .setChecked(mPrefs.getBoolean(Prefs.KEY_WIDGET_TRANSPARENCY, Prefs.DEFAULT_WIDGET_TRANSPARENCY));
    ((CheckBox) findViewById(R.id.choose_text))
            .setChecked(mPrefs.getBoolean(Prefs.KEY_WIDGET_TEXT, Prefs.DEFAULT_WIDGET_TEXT));
    ((EditText) findViewById(R.id.choose_update)).addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String inter = s.toString();
            if (!"".equals(inter) && !"0".equals(inter)) {
                Editor edit = mPrefs.edit();
                edit.putString(Prefs.KEY_CHECK_INTERVAL, inter);
                edit.commit();
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
}

From source file:com.jaspersoft.jasperserver.jrsh.completion.completer.RepositoryNameCompleter.java

private boolean compareCandidatesWithLastInput(String last, List<CharSequence> candidates) {
    for (CharSequence candidate : candidates) {
        if (!candidate.toString().startsWith(last)) {
            return false;
        }//from  www  . j  a  v  a  2  s.c o m
    }
    return true;
}

From source file:org.grails.datastore.mapping.model.types.BasicTypeConverterRegistrar.java

public void register(ConverterRegistry registry) {
    registry.addConverter(new Converter<Date, String>() {
        public String convert(Date date) {
            return String.valueOf(date.getTime());
        }//from w ww .  j  a v a  2 s  . c om
    });

    registry.addConverter(new Converter<Date, Calendar>() {
        public Calendar convert(Date date) {
            final GregorianCalendar calendar = new GregorianCalendar();
            calendar.setTime(date);
            return calendar;
        }
    });

    registry.addConverter(new Converter<Integer, Long>() {
        public Long convert(Integer integer) {
            return integer.longValue();
        }
    });

    registry.addConverter(new Converter<Long, Integer>() {
        public Integer convert(Long longValue) {
            return longValue.intValue();
        }
    });

    registry.addConverter(new Converter<Integer, Double>() {
        public Double convert(Integer integer) {
            return integer.doubleValue();
        }
    });

    registry.addConverter(new Converter<CharSequence, Date>() {
        public Date convert(CharSequence s) {
            try {
                final Long time = Long.valueOf(s.toString());
                return new Date(time);
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });

    registry.addConverter(new Converter<CharSequence, Double>() {
        public Double convert(CharSequence s) {
            try {
                return Double.valueOf(s.toString());
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });

    registry.addConverter(new Converter<CharSequence, Integer>() {
        public Integer convert(CharSequence s) {
            try {
                return Integer.valueOf(s.toString());
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });

    registry.addConverter(new Converter<CharSequence, Long>() {
        public Long convert(CharSequence s) {
            try {
                return Long.valueOf(s.toString());
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });

    registry.addConverter(new Converter<Object, String>() {
        public String convert(Object o) {
            return o.toString();
        }
    });

    registry.addConverter(new Converter<Calendar, String>() {
        public String convert(Calendar calendar) {
            return String.valueOf(calendar.getTime().getTime());
        }
    });

    registry.addConverter(new Converter<CharSequence, Calendar>() {
        public Calendar convert(CharSequence s) {
            try {
                Date date = new Date(Long.valueOf(s.toString()));
                Calendar c = new GregorianCalendar();
                c.setTime(date);
                return c;
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });
}

From source file:it.unimi.di.big.mg4j.index.Index.java

/** Returns a new index using the given URI.
 * //  w ww  .j a  v  a  2s .  com
 * @param ioFactory the factory that will be used to perform I/O, or <code>null</code> (implying the {@link IOFactory#FILESYSTEM_FACTORY} for disk-based indices).
 * @param uri the URI defining the index.
 * @param randomAccess whether the index should be accessible randomly.
 * @param documentSizes if true, document sizes will be loaded (note that sometimes document sizes
 * might be loaded anyway because the compression method for positions requires it).
 * @param maps if true, {@linkplain StringMap term} and {@linkplain PrefixMap prefix} maps will be guessed and loaded (this
 * feature might not be available with some kind of index). 
 */
public static Index getInstance(IOFactory ioFactory, final CharSequence uri, final boolean randomAccess,
        final boolean documentSizes, final boolean maps) throws IOException, ConfigurationException,
        URISyntaxException, ClassNotFoundException, SecurityException, InstantiationException,
        IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    /* If the scheme is mg4j, then we are creating a remote
     * index. If it is null, we assume it is a property file and load it. Otherwise, we
     * assume it is a valid property file URI and try to download it. */

    final String uriString = uri.toString();
    /*if ( uriString.startsWith( "mg4j:" ) ) {
       if ( ioFactory != null ) throw new IllegalAccessError( "You cannot specify a factory for a remote index" );
       final URI u = new URI( uriString );
       return IndexServer.getIndex( u.getHost(), u.getPort(), randomAccess, documentSizes );
    }*/

    final String basename, query;
    if (ioFactory == null)
        ioFactory = IOFactory.FILESYSTEM_FACTORY;

    if (uriString.startsWith("file:")) {
        final URI u = new URI(uriString);
        basename = u.getPath();
        query = u.getQuery();
    } else {
        final int questionMarkPos = uriString.indexOf('?');
        basename = questionMarkPos == -1 ? uriString : uriString.substring(0, questionMarkPos);
        query = questionMarkPos == -1 ? null : uriString.substring(questionMarkPos + 1);
    }

    LOGGER.debug("Searching for an index with basename " + basename + "...");
    final Properties properties = IOFactories.loadProperties(ioFactory,
            basename + DiskBasedIndex.PROPERTIES_EXTENSION);
    LOGGER.debug("Properties: " + properties);

    // We parse the key/value pairs appearing in the query part.
    final EnumMap<UriKeys, String> queryProperties = new EnumMap<UriKeys, String>(UriKeys.class);
    if (query != null) {
        String[] keyValue = query.split(";");
        for (int i = 0; i < keyValue.length; i++) {
            String[] piece = keyValue[i].split("=");
            if (piece.length != 2)
                throw new IllegalArgumentException("Malformed key/value pair: " + keyValue[i]);
            // Convert to standard keys
            boolean found = false;
            for (UriKeys key : UriKeys.values())
                if (found = PropertyBasedDocumentFactory.sameKey(key, piece[0])) {
                    queryProperties.put(key, piece[1]);
                    break;
                }
            if (!found)
                throw new IllegalArgumentException("Unknown key: " + piece[0]);
        }
    }

    // Compatibility with previous versions
    String className = properties.getString(Index.PropertyKeys.INDEXCLASS, "(missing index class)")
            .replace(".dsi.", ".di.");
    Class<?> indexClass = Class.forName(className);

    // It is a cluster.
    if (IndexCluster.class.isAssignableFrom(indexClass))
        return IndexCluster.getInstance(basename, randomAccess, documentSizes, queryProperties);
    // It is a disk-based index.
    return DiskBasedIndex.getInstance(ioFactory, basename, properties, randomAccess, documentSizes, maps,
            queryProperties);
}

From source file:cc.softwarefactory.lokki.android.activities.SignUpActivity.java

private void doSignUp() {
    Log.e(TAG, "Sign up started");
    CharSequence email = aq.id(R.id.email).getText();
    if (email == null) {
        return;//from ww w .ja va 2 s  .  c o  m
    }
    String accountName = email.toString();
    Log.e(TAG, "Email: " + accountName);
    if (accountName.isEmpty()) {
        String errorMessage = getResources().getString(R.string.email_required);
        aq.id(R.id.email).getEditText().setError(errorMessage);
        return;
    }
    PreferenceUtils.setString(this, PreferenceUtils.KEY_USER_ACCOUNT, accountName);
    PreferenceUtils.setString(this, PreferenceUtils.KEY_DEVICE_ID, Utils.getDeviceId());
    MainApplication.userAccount = accountName;

    ServerApi.signUp(this, new SignUpCallback());
    toggleLoading(true);

    String test = PreferenceUtils.getString(this, PreferenceUtils.KEY_USER_ACCOUNT);
    Log.e(TAG, "test" + test);
    mNavigationDrawerFragment.updateTextView(test);
}

From source file:fr.landel.utils.commons.exception.AbstractException.java

/**
 * Constructor with message. To format the message, this method uses
 * {@link String#format} function./*www .  j a  va  2 s .  com*/
 * 
 * @param message
 *            message
 * @param arguments
 *            message arguments
 */
public AbstractException(final CharSequence message, final Object... arguments) {
    super(ArrayUtils.isNotEmpty(arguments) ? String.format(message.toString(), arguments) : message.toString());
}

From source file:de.cosmocode.rendering.CollectionRenderer.java

@Override
public Renderer key(CharSequence key) throws RenderingException {
    mode.checkAllowed(Mode.KEY);/* w  w  w .j  a  v a 2s .  c o m*/
    peekMap().put(key == null ? null : key.toString(), null);
    mode = Mode.KEY;
    return this;
}

From source file:fr.landel.utils.commons.exception.AbstractException.java

/**
 * Constructor with message and exception. To format the message, this
 * method uses {@link String#format} function.
 * /*from  w  w  w. j  a va 2s  . c om*/
 * @param exception
 *            The exception
 * @param message
 *            The message
 * @param arguments
 *            message arguments
 */
public AbstractException(final Throwable exception, final CharSequence message, final Object... arguments) {
    super(ArrayUtils.isNotEmpty(arguments) ? String.format(message.toString(), arguments) : message.toString(),
            exception);
}

From source file:fr.landel.utils.commons.exception.AbstractException.java

/**
 * Constructor. To format the message, this method uses
 * {@link String#format} function./*from  w  w  w.j a va2 s .c  om*/
 *
 * @param cause
 *            the cause
 * @param enableSuppression
 *            whether or not suppression is enabled or disabled
 * @param writableStackTrace
 *            whether or not the stack trace should be writable
 * @param message
 *            message
 * @param arguments
 *            message arguments
 */
protected AbstractException(final Throwable cause, final boolean enableSuppression,
        final boolean writableStackTrace, final CharSequence message, final Object... arguments) {
    super(ArrayUtils.isNotEmpty(arguments) ? String.format(message.toString(), arguments) : message.toString(),
            cause, enableSuppression, writableStackTrace);
}