hprose.util.LinkedCaseInsensitiveMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hprose-java Show documentation
Show all versions of hprose-java Show documentation
Hprose is a High Performance Remote Object Service Engine.
It is a modern, lightweight, cross-language, cross-platform, object-oriented, high performance, remote dynamic communication middleware. It is not only easy to use, but powerful. You just need a little time to learn, then you can use it to easily construct cross language cross platform distributed application system.
Hprose supports many programming languages, for example:
* AAuto Quicker
* ActionScript
* ASP
* C++
* Dart
* Delphi/Free Pascal
* dotNET(C#, Visual Basic...)
* Golang
* Java
* JavaScript
* Node.js
* Objective-C
* Perl
* PHP
* Python
* Ruby
* ...
Through Hprose, You can conveniently and efficiently intercommunicate between those programming languages.
This project is the implementation of Hprose for Java.
The newest version!
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* LinkedCaseInsensitiveMap.java *
* *
* LinkedCaseInsensitiveMap class for Java. *
* *
* LastModified: Aug 4, 2016 *
* Author: Ma Bingyao *
* *
\**********************************************************/
package hprose.util;
import java.util.HashMap;
import java.util.LinkedHashMap;
public class LinkedCaseInsensitiveMap extends LinkedHashMap {
private final HashMap caseInsensitiveKeys;
public LinkedCaseInsensitiveMap(int initialCapacity, float loadFactor) {
super(initialCapacity, loadFactor);
this.caseInsensitiveKeys = new HashMap();
}
public LinkedCaseInsensitiveMap(int initialCapacity) {
super(initialCapacity);
this.caseInsensitiveKeys = new HashMap();
}
public LinkedCaseInsensitiveMap() {
super();
this.caseInsensitiveKeys = new HashMap();
}
public LinkedCaseInsensitiveMap(int initialCapacity,
float loadFactor,
boolean accessOrder) {
super(initialCapacity, loadFactor, accessOrder);
this.caseInsensitiveKeys = new HashMap();
}
private String convertKey(Object key) {
return ((key instanceof char[]) ? new String((char[]) key) : key.toString()).toLowerCase();
}
@Override
public V put(K key, V value) {
this.caseInsensitiveKeys.put(convertKey(key), key);
return super.put(key, value);
}
@Override
public boolean containsKey(Object key) {
return (key instanceof String && this.caseInsensitiveKeys.containsKey(convertKey(key)));
}
@Override
public V get(Object key) {
return super.get(this.caseInsensitiveKeys.get(convertKey(key)));
}
@Override
public V remove(Object key) {
return super.remove(this.caseInsensitiveKeys.remove(convertKey(key)));
}
@Override
public void clear() {
this.caseInsensitiveKeys.clear();
super.clear();
}
}