am ada18333: Merge change 8196 into donut
Merge commit 'ada18333257cdc14d3cafbddf5d1395574e5132b' * commit 'ada18333257cdc14d3cafbddf5d1395574e5132b': Refactored AndroidXPathFactory into sdklib.
This commit is contained in:
committed by
Android Git Automerger
commit
b0ef3fb3bd
@@ -27,10 +27,10 @@ import com.android.ide.eclipse.adt.internal.editors.manifest.pages.OverviewPage;
|
||||
import com.android.ide.eclipse.adt.internal.editors.manifest.pages.PermissionPage;
|
||||
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiAttributeNode;
|
||||
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
|
||||
import com.android.ide.eclipse.adt.internal.project.AndroidXPathFactory;
|
||||
import com.android.ide.eclipse.adt.internal.resources.manager.ResourceMonitor;
|
||||
import com.android.ide.eclipse.adt.internal.resources.manager.ResourceMonitor.IFileListener;
|
||||
import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
|
||||
import com.android.sdklib.xml.AndroidXPathFactory;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
|
||||
@@ -21,8 +21,8 @@ import com.android.ide.eclipse.adt.AndroidConstants;
|
||||
import com.android.ide.eclipse.adt.internal.editors.AndroidEditor;
|
||||
import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor;
|
||||
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
|
||||
import com.android.ide.eclipse.adt.internal.project.AndroidXPathFactory;
|
||||
import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
|
||||
import com.android.sdklib.xml.AndroidXPathFactory;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.android.ide.eclipse.adt.internal.editors.AndroidEditor;
|
||||
import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor;
|
||||
import com.android.ide.eclipse.adt.internal.editors.resources.descriptors.ResourcesDescriptors;
|
||||
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
|
||||
import com.android.ide.eclipse.adt.internal.project.AndroidXPathFactory;
|
||||
import com.android.sdklib.xml.AndroidXPathFactory;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.adt.internal.project;
|
||||
|
||||
import com.android.sdklib.SdkConstants;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
/**
|
||||
* XPath factory with automatic support for the android namespace.
|
||||
*/
|
||||
public class AndroidXPathFactory {
|
||||
public final static String DEFAULT_NS_PREFIX = "android"; //$NON-NLS-1$
|
||||
|
||||
private final static XPathFactory sFactory = XPathFactory.newInstance();
|
||||
|
||||
/** Namespace context for Android resource XML files. */
|
||||
private static class AndroidNamespaceContext implements NamespaceContext {
|
||||
private String mAndroidPrefix;
|
||||
|
||||
/**
|
||||
* Construct the context with the prefix associated with the android namespace.
|
||||
* @param androidPrefix the Prefix
|
||||
*/
|
||||
public AndroidNamespaceContext(String androidPrefix) {
|
||||
mAndroidPrefix = androidPrefix;
|
||||
}
|
||||
|
||||
public String getNamespaceURI(String prefix) {
|
||||
if (prefix != null) {
|
||||
if (prefix.equals(mAndroidPrefix)) {
|
||||
return SdkConstants.NS_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
return XMLConstants.NULL_NS_URI;
|
||||
}
|
||||
|
||||
public String getPrefix(String namespaceURI) {
|
||||
// This isn't necessary for our use.
|
||||
assert false;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator<?> getPrefixes(String namespaceURI) {
|
||||
// This isn't necessary for our use.
|
||||
assert false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new XPath object, specifying which prefix in the query is used for the
|
||||
* android namespace.
|
||||
* @param androidPrefix The namespace prefix.
|
||||
*/
|
||||
public static XPath newXPath(String androidPrefix) {
|
||||
XPath xpath = sFactory.newXPath();
|
||||
xpath.setNamespaceContext(new AndroidNamespaceContext(androidPrefix));
|
||||
return xpath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new XPath object using the default prefix for the android namespace.
|
||||
* @see #DEFAULT_NS_PREFIX
|
||||
*/
|
||||
public static XPath newXPath() {
|
||||
return newXPath(DEFAULT_NS_PREFIX);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.ide.eclipse.adt.internal.refactorings.extractstring;
|
||||
|
||||
import com.android.ide.eclipse.adt.internal.project.AndroidXPathFactory;
|
||||
import com.android.sdklib.xml.AndroidXPathFactory;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
||||
Reference in New Issue
Block a user