KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > util > QualifiedTypeNameHistory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.corext.util;
12
13 import org.w3c.dom.Element JavaDoc;
14
15 public class QualifiedTypeNameHistory extends History {
16     
17     private static final String JavaDoc NODE_ROOT= "qualifiedTypeNameHistroy"; //$NON-NLS-1$
18
private static final String JavaDoc NODE_TYPE_INFO= "fullyQualifiedTypeName"; //$NON-NLS-1$
19
private static final String JavaDoc NODE_NAME= "name"; //$NON-NLS-1$
20

21     private static QualifiedTypeNameHistory fgInstance;
22     
23     
24     public static QualifiedTypeNameHistory getDefault() {
25         if (fgInstance == null)
26             fgInstance= new QualifiedTypeNameHistory("QualifiedTypeNameHistory.xml"); //$NON-NLS-1$
27

28         return fgInstance;
29     }
30     
31     public QualifiedTypeNameHistory(String JavaDoc fileName) {
32         super(fileName, NODE_ROOT, NODE_TYPE_INFO);
33         load();
34     }
35
36     /**
37      * {@inheritDoc}
38      */

39     protected void setAttributes(Object JavaDoc object, Element JavaDoc element) {
40         element.setAttribute(NODE_NAME, (String JavaDoc)object);
41     }
42
43     /**
44      * {@inheritDoc}
45      */

46     protected Object JavaDoc createFromElement(Element JavaDoc element) {
47         return element.getAttribute(NODE_NAME);
48     }
49
50     /**
51      * {@inheritDoc}
52      */

53     protected Object JavaDoc getKey(Object JavaDoc object) {
54         return object;
55     }
56     
57     public static int getBoost(String JavaDoc fullyQualifiedTypeName, int min, int max) {
58         float position= getDefault().getNormalizedPosition(fullyQualifiedTypeName);
59         int dist= max - min;
60         return Math.round(position * dist) + min;
61     }
62
63     public static void remember(String JavaDoc fullyQualifiedTypeName) {
64         getDefault().accessed(fullyQualifiedTypeName);
65     }
66
67 }
68
Popular Tags