Ejemplo n.º 1
0
 private void load3() {
   String path = getPath(); // invokes load2() and load1()
   String directory = StringUtils.beforeLast(path, "/");
   if (directory.equals("")) {
     // make root directory "/"
     _pathDirectory = "/";
   } else {
     _pathDirectory = directory;
   }
   _pathFile = path.substring(directory.length() + 1);
   _pathSuffix = StringUtils.afterLast(_pathFile, ".");
 }
Ejemplo n.º 2
0
  /** add a mapping for this {@link TypeMapping}'s type and alias */
  public void addMapping(final TypeMapping mapping) {
    final String typeAlias = mapping.getTypeAlias();
    if (StringUtils.empty(typeAlias)) {
      throw new IllegalArgumentException("typeAlias must not be empty");
    }

    {
      // put alias if unknown
      final TypeMapping prev = _mappingsByAlias.putIfAbsent(typeAlias, mapping);
      if (prev != null && prev != mapping) {
        throw new IllegalArgumentException("duplicate type alias " + mapping.getTypeAlias());
      }
    }

    {
      // put class if unknown
      final TypeMapping prev = _mappingsByClass.putIfAbsent(mapping.getTypeClass(), mapping);
      if (prev != null && prev != mapping) {
        _mappingsByAlias.remove(typeAlias);
        throw new IllegalArgumentException(
            "duplicate type class " + mapping.getTypeClass().getName());
      }
    }
  }
Ejemplo n.º 3
0
 /** @return {@link TypeMapping} for this alias or null */
 public TypeMapping getTypeMapping(final String typeAlias) {
   if (StringUtils.empty(typeAlias)) {
     return null;
   }
   return _mappingsByAlias.get(typeAlias);
 }