本文整理汇总了Java中com.intellij.util.containers.StringInterner类的典型用法代码示例。如果您正苦于以下问题:Java StringInterner类的具体用法?Java StringInterner怎么用?Java StringInterner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringInterner类属于com.intellij.util.containers包,在下文中一共展示了StringInterner类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: findRelative
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
@Nullable
private Node<T> findRelative(final String text, final int nameStartIndex, final boolean create, final StringInterner table) {
if (myChildren == null && !create) {
return null;
}
final int textLen = text.length();
final int separatorIdx = text.indexOf(mySeparator, nameStartIndex);
final int childNameEnd = separatorIdx >= 0 ? separatorIdx : textLen;
if (myChildren != null) {
final Node<T> child = myChildren.get(text.substring(nameStartIndex, childNameEnd));
if (child != null) {
if (separatorIdx < 0) {
return child;
}
return child.findRelative(text, childNameEnd + 1, create, table);
}
}
if (create) {
return addChild(table, text, nameStartIndex, childNameEnd);
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:TreeBasedMap.java
示例2: addChild
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
@NotNull
private Node<T> addChild(final StringInterner table, final String text, final int nameStartIndex, final int nameEndIndex) {
if (myChildren == null) {
myChildren = new HashMap<String, Node<T>>(3, 0.95f);
}
Node<T> newChild = new Node<T>();
final String key = table.intern(text.substring(nameStartIndex, nameEndIndex));
myChildren.put(key, newChild);
if (nameEndIndex == text.length()) {
return newChild;
}
Node<T> restNodes = newChild.findRelative(text, nameEndIndex + 1, true, table);
assert restNodes != null;
return restNodes;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:TreeBasedMap.java
示例3: readExternal
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
@Override
public void readExternal(@NotNull Element element) {
super.readExternal(element);
final String version = element.getAttributeValue(VERSION_TAG);
if (version == null || !version.equals(VALID_VERSION)) {
element = InspectionProfileConvertor.convertToNewFormat(element, this);
}
final Element highlightElement = element.getChild(USED_LEVELS);
if (highlightElement != null) {
// from old profiles
((SeverityProvider)getProfileManager()).getOwnSeverityRegistrar().readExternal(highlightElement);
}
StringInterner interner = new StringInterner();
for (Element toolElement : element.getChildren(INSPECTION_TOOL_TAG)) {
// make clone to avoid retaining memory via o.parent pointers
toolElement = toolElement.clone();
JDOMUtil.internElement(toolElement, interner);
myUninstalledInspectionsSettings.put(toolElement.getAttributeValue(CLASS_TAG), toolElement);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:InspectionProfileImpl.java
示例4: internElement
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
public static void internElement(@NotNull Element element, @NotNull StringInterner interner) {
element.setName(interner.intern(element.getName()));
for (Attribute attr : element.getAttributes()) {
attr.setName(interner.intern(attr.getName()));
attr.setValue(interner.intern(attr.getValue()));
}
for (Content o : element.getContent()) {
if (o instanceof Element) {
internElement((Element)o, interner);
}
else if (o instanceof Text) {
((Text)o).setText(interner.intern(o.getValue()));
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JDOMUtil.java
示例5: convert
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
public static List<String> convert(StringInterner interner, String value, char delim) {
final List<String> result = new ArrayList<String>();
int start = 0;
final int len = value.length();
for (int idx = 0; idx < len; idx++) {
if (value.charAt(idx) == delim) {
result.add(interner.intern(value.substring(start, idx)));
start = idx + 1;
}
}
if (start < value.length()) {
result.add(interner.intern(value.substring(start)));
}
if (len > 0 && value.charAt(len-1) == delim) { // ends with delimiter
result.add("");
}
return result;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:InternedPath.java
示例6: load
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
@NotNull
public static TreeMap<String, Element> load(@NotNull Element rootElement, @Nullable PathMacroSubstitutor pathMacroSubstitutor, boolean intern) {
if (pathMacroSubstitutor != null) {
pathMacroSubstitutor.expandPaths(rootElement);
}
StringInterner interner = intern ? new StringInterner() : null;
List<Element> children = rootElement.getChildren(COMPONENT);
TreeMap<String, Element> map = new TreeMap<String, Element>();
for (Element element : children) {
String name = getComponentNameIfValid(element);
if (name == null || !(element.getAttributes().size() > 1 || !element.getChildren().isEmpty())) {
continue;
}
if (interner != null) {
JDOMUtil.internElement(element, interner);
}
map.put(name, element);
if (pathMacroSubstitutor instanceof TrackingPathMacroSubstitutor) {
((TrackingPathMacroSubstitutor)pathMacroSubstitutor).addUnknownMacros(name, PathMacrosCollector.getMacroNames(element));
}
// remove only after "getMacroNames" - some PathMacroFilter requires element name attribute
element.removeAttribute(NAME);
}
return map;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:FileStorageCoreUtil.java
示例7: copyElements
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
@Nullable
private static List<Element> copyElements(@Nullable Element[] elements, StringInterner interner) {
if (elements == null || elements.length == 0) {
return null;
}
List<Element> result = new SmartList<Element>();
for (Element extensionsRoot : elements) {
for (Element element : extensionsRoot.getChildren()) {
JDOMUtil.internElement(element, interner);
result.add(element);
}
}
return result;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:IdeaPluginDescriptorImpl.java
示例8: readExternal
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
@Override
public void readExternal(@Nonnull Element element) throws InvalidDataException {
super.readExternal(element);
if (!ApplicationManager.getApplication().isUnitTestMode() || myBaseProfile == null) {
// todo remove this strange side effect
myBaseProfile = getDefaultProfile();
}
final String version = element.getAttributeValue(VERSION_TAG);
if (version == null || !version.equals(VALID_VERSION)) {
element = InspectionProfileConvertor.convertToNewFormat(element, this);
}
final Element highlightElement = element.getChild(USED_LEVELS);
if (highlightElement != null) {
// from old profiles
((SeverityProvider)getProfileManager()).getOwnSeverityRegistrar().readExternal(highlightElement);
}
StringInterner interner = new StringInterner();
for (Element toolElement : element.getChildren(INSPECTION_TOOL_TAG)) {
// make clone to avoid retaining memory via o.parent pointers
toolElement = toolElement.clone();
JDOMUtil.internStringsInElement(toolElement, interner);
myUninstalledInspectionsSettings.put(toolElement.getAttributeValue(CLASS_TAG), toolElement);
}
}
开发者ID:consulo,项目名称:consulo,代码行数:28,代码来源:InspectionProfileImpl.java
示例9: load
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
public void load(@Nonnull Element rootElement, @Nullable PathMacroSubstitutor pathMacroSubstitutor, boolean intern) {
if (pathMacroSubstitutor != null) {
pathMacroSubstitutor.expandPaths(rootElement);
}
StringInterner interner = intern ? new StringInterner() : null;
for (Iterator<Element> iterator = rootElement.getChildren(COMPONENT).iterator(); iterator.hasNext(); ) {
Element element = iterator.next();
String name = getComponentNameIfValid(element);
if (name == null || !(element.getAttributes().size() > 1 || !element.getChildren().isEmpty())) {
continue;
}
iterator.remove();
if (interner != null) {
JDOMUtil.internStringsInElement(element, interner);
}
myStates.put(name, element);
if (pathMacroSubstitutor instanceof TrackingPathMacroSubstitutor) {
((TrackingPathMacroSubstitutor)pathMacroSubstitutor).addUnknownMacros(name, PathMacrosService.getInstance().getMacroNames(element));
}
// remove only after "getMacroNames" - some PathMacroFilter requires element name attribute
element.removeAttribute(NAME);
}
}
开发者ID:consulo,项目名称:consulo,代码行数:29,代码来源:StorageData.java
示例10: internStringsInElement
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
/**
* Replace all strings in JDOM {@code element} with their interned variants with the help of {@code interner} to reduce memory.
* It's better to use {@link #internElement(Element)} though because the latter will intern the Element instances too.
*/
public static void internStringsInElement(@Nonnull Element element, @Nonnull StringInterner interner) {
element.setName(intern(interner, element.getName()));
for (Attribute attr : element.getAttributes()) {
attr.setName(intern(interner, attr.getName()));
attr.setValue(intern(interner, attr.getValue()));
}
for (Content o : element.getContent()) {
if (o instanceof Element) {
Element e = (Element)o;
internStringsInElement(e, interner);
}
else if (o instanceof Text) {
Text text = (Text)o;
text.setText(intern(interner, text.getText()));
}
else if (o instanceof Comment) {
Comment comment = (Comment)o;
comment.setText(intern(interner, comment.getText()));
}
else {
throw new IllegalArgumentException("Wrong node: " + o);
}
}
}
开发者ID:consulo,项目名称:consulo,代码行数:31,代码来源:JDOMUtil.java
示例11: copyElements
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
@Nullable
private static List<Element> copyElements(@Nullable Element[] elements, StringInterner interner) {
if (elements == null || elements.length == 0) {
return null;
}
List<Element> result = new SmartList<>();
for (Element extensionsRoot : elements) {
for (Element element : extensionsRoot.getChildren()) {
JDOMUtil.internStringsInElement(element, interner);
result.add(element);
}
}
return result;
}
开发者ID:consulo,项目名称:consulo,代码行数:16,代码来源:IdeaPluginDescriptorImpl.java
示例12: TreeBasedPathsSet
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
public TreeBasedPathsSet(StringInterner interner, char separator) {
myMap = new TreeBasedMap<Object>(interner, separator);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:TreeBasedPathsSet.java
示例13: TreeBasedMap
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
public TreeBasedMap(StringInterner table, final char separator) {
myInterner = table;
mySeparator = separator;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:TreeBasedMap.java
示例14: loadFrom
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
@NotNull
public static Map<String, Element> loadFrom(@Nullable VirtualFile dir, @Nullable TrackingPathMacroSubstitutor pathMacroSubstitutor) {
if (dir == null || !dir.exists()) {
return Collections.emptyMap();
}
StringInterner interner = new StringInterner();
Map<String, Element> fileToState = new THashMap<String, Element>();
for (VirtualFile file : dir.getChildren()) {
// ignore system files like .DS_Store on Mac
if (!StringUtilRt.endsWithIgnoreCase(file.getNameSequence(), FileStorageCoreUtil.DEFAULT_EXT)) {
continue;
}
try {
if (file.getLength() == 0) {
LOG.warn("Ignore empty file " + file.getPath());
continue;
}
Element element = JDOMUtil.load(file.getInputStream());
String componentName = FileStorageCoreUtil.getComponentNameIfValid(element);
if (componentName == null) {
continue;
}
if (!element.getName().equals(FileStorageCoreUtil.COMPONENT)) {
LOG.error("Incorrect root tag name (" + element.getName() + ") in " + file.getPresentableUrl());
continue;
}
List<Element> elementChildren = element.getChildren();
if (elementChildren.isEmpty()) {
continue;
}
Element state = (Element)elementChildren.get(0).detach();
if (JDOMUtil.isEmpty(state)) {
continue;
}
JDOMUtil.internElement(state, interner);
if (pathMacroSubstitutor != null) {
pathMacroSubstitutor.expandPaths(state);
pathMacroSubstitutor.addUnknownMacros(componentName, PathMacrosCollector.getMacroNames(state));
}
fileToState.put(file.getName(), state);
}
catch (Throwable e) {
LOG.warn("Unable to load state", e);
}
}
return fileToState;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:DirectoryStorageUtil.java
示例15: readExternal
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
public void readExternal(@NotNull Document document, @NotNull URL url, boolean ignoreMissingInclude) throws InvalidDataException, FileNotFoundException {
document = JDOMXIncluder.resolve(document, url.toExternalForm(), ignoreMissingInclude);
Element rootElement = document.getRootElement();
JDOMUtil.internElement(rootElement, new StringInterner());
readExternal(document.getRootElement());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:IdeaPluginDescriptorImpl.java
示例16: InternedPath
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
public InternedPath(StringInterner interner, String url, final char separator) {
myValue = convert(interner, url, separator);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:4,代码来源:InternedPath.java
示例17: intern
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
@NotNull
private static String intern(@NotNull final StringInterner interner, @NotNull final String s) {
synchronized (interner) {
return interner.intern(s);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:7,代码来源:JDOMUtil.java
示例18: loadFrom
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
public void loadFrom(@Nullable VirtualFile dir, @Nullable TrackingPathMacroSubstitutor pathMacroSubstitutor) {
if (dir == null || !dir.exists()) {
return;
}
StringInterner interner = new StringInterner();
for (VirtualFile file : dir.getChildren()) {
if (!isStorageFile(file)) {
continue;
}
try {
Element element = JDOMUtil.loadDocument(file.contentsToByteArray()).getRootElement();
String name = StorageData.getComponentNameIfValid(element);
if (name == null) {
continue;
}
if (!element.getName().equals(StorageData.COMPONENT)) {
LOG.error("Incorrect root tag name (" + element.getName() + ") in " + file.getPresentableUrl());
continue;
}
List<Element> elementChildren = element.getChildren();
if (elementChildren.isEmpty()) {
continue;
}
Element state = (Element)elementChildren.get(0).detach();
JDOMUtil.internStringsInElement(state, interner);
if (pathMacroSubstitutor != null) {
pathMacroSubstitutor.expandPaths(state);
pathMacroSubstitutor.addUnknownMacros(name, PathMacrosService.getInstance().getMacroNames(state));
}
setState(name, file.getName(), state);
}
catch (IOException | JDOMException e) {
LOG.info("Unable to load state", e);
}
}
}
开发者ID:consulo,项目名称:consulo,代码行数:42,代码来源:DirectoryStorageData.java
示例19: intern
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
@Nonnull
private static String intern(@Nonnull final StringInterner interner, @Nonnull final String s) {
return interner.intern(s);
}
开发者ID:consulo,项目名称:consulo,代码行数:5,代码来源:JDOMUtil.java
示例20: readExternal
import com.intellij.util.containers.StringInterner; //导入依赖的package包/类
public void readExternal(@Nonnull Document document, @Nonnull URL url, boolean ignoreMissingInclude) throws InvalidDataException, FileNotFoundException {
document = JDOMXIncluder.resolve(document, url.toExternalForm(), ignoreMissingInclude);
Element rootElement = document.getRootElement();
JDOMUtil.internStringsInElement(rootElement, new StringInterner());
readExternal(document.getRootElement());
}
开发者ID:consulo,项目名称:consulo,代码行数:7,代码来源:IdeaPluginDescriptorImpl.java
注:本文中的com.intellij.util.containers.StringInterner类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论