com.ibm.icu.text.RemoveTransliterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.commerce.currency.service
Show all versions of com.liferay.commerce.currency.service
Liferay Commerce Currency Service
/*
*******************************************************************************
* Copyright (C) 1996-2014, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.text;
/**
* A transliterator that removes characters. This is useful in conjunction
* with a filter.
*/
class RemoveTransliterator extends Transliterator {
/**
* ID for this transliterator.
*/
private static final String _ID = "Any-Remove";
/**
* System registration hook.
*/
static void register() {
Transliterator.registerFactory(_ID, new Transliterator.Factory() {
public Transliterator getInstance(String ID) {
return new RemoveTransliterator();
}
});
Transliterator.registerSpecialInverse("Remove", "Null", false);
}
/**
* Constructs a transliterator.
*/
public RemoveTransliterator() {
super(_ID, null);
}
/**
* Implements {@link Transliterator#handleTransliterate}.
*/
protected void handleTransliterate(Replaceable text,
Position index, boolean incremental) {
// Our caller (filteredTransliterate) has already narrowed us
// to an unfiltered run. Delete it.
text.replace(index.start, index.limit, "");
int len = index.limit - index.start;
index.contextLimit -= len;
index.limit -= len;
}
/* (non-Javadoc)
* @see com.ibm.icu.text.Transliterator#addSourceTargetSet(boolean, com.ibm.icu.text.UnicodeSet, com.ibm.icu.text.UnicodeSet)
*/
@Override
public void addSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet targetSet) {
// intersect myFilter with the input filter
UnicodeSet myFilter = getFilterAsUnicodeSet(inputFilter);
sourceSet.addAll(myFilter);
// do nothing with the target
}
}