java.lang.Package.toString()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中java.lang.Package.toString()方法的一些代码示例,展示了Package.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Package.toString()方法的具体详情如下:
包路径:java.lang.Package
类名称:Package
方法名:toString

Package.toString介绍

[英]Returns the string representation of this Package. Its value is the string "package " and the package name. If the package title is defined it is appended. If the package version is defined it is appended.
[中]返回此包的字符串表示形式。它的值是字符串“package”和包名。如果定义了包标题,则会附加该标题。如果定义了软件包版本,则会追加该版本。

代码示例

代码示例来源:origin: apache/usergrid

protected void configureServlets() {
    //noinspection unchecked
    install( new GuicyFigModule( ServletFig.class, CoordinatorFig.class ) );
    install( new ChopClientModule() );

    // Hook Jersey into Guice Servlet
    bind( GuiceContainer.class );

    // Hook Jackson into Jersey as the POJO <-> JSON mapper
    bind( JacksonJsonProvider.class ).asEagerSingleton();

    bind( IController.class ).to( Controller.class );
    bind( RunnerRegistry.class ).to( RunnerRegistryImpl.class );
    bind( RunManager.class ).to( RunManagerImpl.class );

    bind( ResetResource.class );
    bind( StopResource.class );
    bind( StartResource.class );
    bind( StatsResource.class );
    bind( StatusResource.class );

    Map<String, String> params = new HashMap<String, String>();
    params.put( PACKAGES_KEY, getClass().getPackage().toString() );
    serve( "/*" ).with( GuiceContainer.class, params );
  }
}

代码示例来源:origin: geotools/geotools

/**
 * Checks if the provided iterator implements {@link Closeable}.
 *
 * <p>Any problems are logged at {@link Level#FINE}.
 */
public static void close(Iterator<?> iterator) {
  if (iterator != null && iterator instanceof Closeable) {
    try {
      ((Closeable) iterator).close();
    } catch (IOException e) {
      String name = iterator.getClass().getPackage().toString();
      Logger log = Logger.getLogger(name);
      log.log(Level.FINE, e.getMessage(), e);
    }
  }
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * Modules should extend {@link BaseModuleContextSensitiveTest}, not this class. If they extend
 * this class, then they won't work right when run in batches.
 * 
 * @throws Exception
 */
@Before
public void checkNotModule() throws Exception {
  if (this.getClass().getPackage().toString().contains("org.openmrs.module.")
      && !(this instanceof BaseModuleContextSensitiveTest)) {
    throw new RuntimeException(
        "Module unit test classes should extend BaseModuleContextSensitiveTest, not just BaseContextSensitiveTest");
  }
}

代码示例来源:origin: stackoverflow.com

@ApplicationPath("/myapp")
public class MyApplication extends ResourceConfig {
  public MyApplication() {
    packages(getClass().getPackage().toString());
    register(ContainerResourceFilterTest.class);
  }
}

代码示例来源:origin: net.gltd.gtms/gtmsutil

private static String getPackageSuffixFromClass(Class caller) {
  String packageSuffix = "";
  String[] packageComponents = caller.getClass().getPackage().toString().split("\\.");
  if (packageComponents != null) {
    if (packageComponents.length > 0) {
      packageSuffix = packageComponents[packageComponents.length - 1];
    }
  }
  return packageSuffix;
}

代码示例来源:origin: net.serenity-bdd/serenity-core

private boolean isSlow(Method method) {
    for(String slowDomain : slowDomains) {
      if (method.getDeclaringClass().getPackage().toString().contains(slowDomain)) {
        return true;
      }
    }
    return false;
  }
}

代码示例来源:origin: com.guigarage/ui-basics

public static String getResourceUrl(Class loaderClass, String resourceName) {
    URL resourceUrl = loaderClass.getResource(resourceName);
    if (resourceUrl == null) {
      throw new NullPointerException("Can't find resource " + resourceName + " in package " + loaderClass.getPackage().toString());
    }
    return resourceUrl.toExternalForm();
  }
}

代码示例来源:origin: stackoverflow.com

if (this.getClass().getPackage().toString().contains("ios")) {
  platform = iOS;
}

代码示例来源:origin: stackoverflow.com

Package foo = Package.getPackage("javax.servlet");

if(null != foo){
 foo.toString();
}else{
 System.out.println("Doesn't Exist");
}

代码示例来源:origin: org.patterntesting/patterntesting-rt

/**
 * Gets the loaded packages.
 *
 * @return the loaded packages
 *
 * @see ClasspathMonitorMBean#getLoadedPackages()
 */
@Override
public String[] getLoadedPackages() {
  Package[] packages = this.classpathDigger.getLoadedPackageArray();
  String[] strings = new String[packages.length];
  for (int i = 0; i < packages.length; i++) {
    strings[i] = packages[i].toString();
  }
  Arrays.sort(strings);
  return strings;
}

代码示例来源:origin: de.aosd.clazzfish/clazzfish-monitor

/**
 * Gets the loaded packages.
 *
 * @return the loaded packages
 *
 * @see ClasspathMonitorMBean#getLoadedPackages()
 */
@Override
public String[] getLoadedPackages() {
  Package[] packages = this.classpathDigger.getLoadedPackageArray();
  String[] strings = new String[packages.length];
  for (int i = 0; i < packages.length; i++) {
    strings[i] = packages[i].toString();
  }
  Arrays.sort(strings);
  return strings;
}

代码示例来源:origin: net.sf.patterntesting/patterntesting-rt

/**
 * Gets the loaded packages.
 *
 * @return the loaded packages
 *
 * @see ClasspathMonitorMBean#getLoadedPackages()
 */
public String[] getLoadedPackages() {
  Package[] packages = this.classpathDigger.getLoadedPackageArray();
  String[] strings = new String[packages.length];
  for (int i = 0; i < packages.length; i++) {
    strings[i] = packages[i].toString();
  }
  Arrays.sort(strings);
  return strings;
}

代码示例来源:origin: QihooTest/Leo

private Map<String, Object> getJavaFileData(JavaCaseInfo javaInfo){
  Map<String, Object> data = new TreeMap<String, Object>();
  data.put("javaInfo", javaInfo);
  Map<String, String> clsInfo = new TreeMap<>();
  String impotInfo = javaInfo.getCls().getPackage().toString();
  impotInfo = impotInfo.substring(8)+"."+javaInfo.getCls().getSimpleName();
  clsInfo.put("importInfo", impotInfo);
  clsInfo.put("className", javaInfo.getCls().getSimpleName());
  clsInfo.put("method", javaInfo.getMethod());
  data.put("clsInfo", clsInfo);
  return data;
}

代码示例来源:origin: Var3D/var3dframe

private FileHandle getStageKotlinFile(VStage stage) {
  if (stageFiles.get(stage) != null) return stageFiles.get(stage);
  String proName = Gdx.files.getLocalStoragePath().replaceAll("\\/android\\/assets\\/", "");
  String pack = stage.getClass().getPackage().toString().replaceAll("package ", "");
  pack = pack.replaceAll("\\.", "/");
  String tryPath = proName + "/core/src/" + pack + "/" + stage.getClass().getSimpleName() + ".kt";
  FileHandle fileHandle = Gdx.files.absolute(tryPath);
  if (!fileHandle.exists()) {
    //ڣһ·
    tryPath = proName + "/core/src/main/java/" + pack + "/" + stage.getClass().getSimpleName() + ".kt";
    fileHandle = Gdx.files.absolute(tryPath);
  }
  if (!fileHandle.exists()) return null;
  stageFiles.put(stage, fileHandle);
  fileType = FileType.Kotlin;
  return fileHandle;
}

代码示例来源:origin: Var3D/var3dframe

private FileHandle getStageJavaFile(VStage stage) {
  if (stageFiles.get(stage) != null) return stageFiles.get(stage);
  String proName = Gdx.files.getLocalStoragePath().replaceAll("\\/android\\/assets\\/", "");
  String pack = stage.getClass().getPackage().toString().replaceAll("package ", "");
  pack = pack.replaceAll("\\.", "/");
  String tryPath = proName + "/core/src/" + pack + "/" + stage.getClass().getSimpleName() + ".java";
  FileHandle fileHandle = Gdx.files.absolute(tryPath);
  if (!fileHandle.exists()) {
    //ڣһ·
    tryPath = proName + "/core/src/main/java/" + pack + "/" + stage.getClass().getSimpleName() + ".java";
    fileHandle = Gdx.files.absolute(tryPath);
  }
  if (!fileHandle.exists()) return null;
  stageFiles.put(stage, fileHandle);
  fileType = FileType.Java;
  return fileHandle;
}

代码示例来源:origin: cc.mallet/mallet

public CommandOption (Class owner, java.lang.String name, java.lang.String argName,
           Class argType, boolean argRequired,
           java.lang.String shortdoc, java.lang.String longdoc)
{
  this.owner = owner;
  this.name = name;
  this.argName = argName;
  this.argType = argType;
  this.argRequired = argRequired;
  this.shortdoc = shortdoc;
  this.longdoc = longdoc;
  Package p = owner.getPackage();
  this.fullName = (p != null ? p.toString() : "") + name;
  if (interpreter == null)
    interpreter = new BshInterpreter ();
  if (owner != CommandOption.class) {
    CommandOption.List options = (CommandOption.List) class2options.get (owner);
    if (options == null) {
      options = new CommandOption.List ("");
      class2options.put (owner, options);
    }
    options.add (this);
  }
}

代码示例来源:origin: de.julielab/jcore-mallet-0.4

public CommandOption (Class owner, java.lang.String name, java.lang.String argName,
                      Class argType, boolean argRequired,
                      java.lang.String shortdoc, java.lang.String longdoc)
{
  this.owner = owner;
  this.name = name;
  this.argName = argName;
  this.argType = argType;
  this.argRequired = argRequired;
  this.shortdoc = shortdoc;
  this.longdoc = longdoc;
Package p = owner.getPackage();
  this.fullName = (p != null ? p.toString() : "") + name;
  if (interpreter == null)
    interpreter = new BshInterpreter ();
  if (owner != CommandOption.class) {
    CommandOption.List options = (CommandOption.List) class2options.get (owner);
    if (options == null) {
      options = new CommandOption.List ("");
      class2options.put (owner, options);
    }
    options.add (this);
  }
}

代码示例来源:origin: org.kie.workbench.forms/kie-wb-common-forms-jbpm-integration-backend

protected DataObject getClientDataObject() {
    DataObject client = new DataObjectImpl(Client.class.getPackage().toString(),
                        Client.class.getSimpleName());

    client.addProperty("id",
              Long.class.getName(),
              false,
              null);
    client.addProperty("name",
              String.class.getName(),
              false,
              null);
    client.addProperty("lastName",
              String.class.getName(),
              false,
              null);
    return client;
  }
}

代码示例来源:origin: org.kie.workbench.forms/kie-wb-common-forms-jbpm-integration-backend

protected DataObject getExpenseDataObject() {
  DataObject expense = new DataObjectImpl(Expense.class.getPackage().toString(),
                      Expense.class.getSimpleName());
  expense.addProperty("id",
            Long.class.getName(),
            false,
            null);
  expense.addProperty("date",
            Date.class.getName(),
            false,
            null);
  expense.addProperty("client",
            Client.class.getName(),
            false,
            null);
  expense.addProperty("lines",
            Line.class.getName(),
            true,
            List.class.getName());
  return expense;
}

代码示例来源:origin: org.kie.workbench.forms/kie-wb-common-forms-jbpm-integration-backend

protected DataObject getLineDataObject() {
  DataObject expense = new DataObjectImpl(Line.class.getPackage().toString(),
                      Line.class.getSimpleName());
  expense.addProperty("id",
            Long.class.getName(),
            false,
            null);
  expense.addProperty("date",
            Date.class.getName(),
            false,
            null);
  expense.addProperty("product",
            String.class.getName(),
            false,
            null);
  expense.addProperty("price",
            Double.class.getName(),
            false,
            null);
  return expense;
}

相关文章