Changeset 7610


Ignore:
Timestamp:
Feb 27, 2019, 2:18:43 PM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2151: Pre-compile all JSP pages before releases

Changed some more methods to use generic return values to get rid of the last "checked" warning in the JSP files.

Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/src/docbook/appendix/incompatible.xml

    r7609 r7610  
    8080      are several similar changes in the <classname docapi="net.sf.basedb.core">ItemContext</classname>
    8181      class as well as in <classname docapi="net.sf.basedb.core">SessionControl</classname>,
     82      <classname docapi="net.sf.basedb.core">Annotation</classname>,
     83      <classname docapi="net.sf.basedb.core">AnnotationType</classname>
    8284      <classname docapi="net.sf.basedb.clients.web.formatter">FormatterFactory</classname>,
    8385      <classname docapi="net.sf.basedb.core">ParameterValues</classname> and several other
  • trunk/src/clients/web/net/sf/basedb/clients/web/ExperimentExplorer.java

    r7516 r7610  
    891891  }
    892892 
    893   @SuppressWarnings("unchecked")
    894893  private void initReporterCache(DbControl dc)
    895894  {
     
    901900      StaticCache staticCache = Application.getStaticCache();
    902901      String cacheKey = "explorer/" + (id % 1000) + "/poslist-" + id + ".ser";
    903       List<Integer> posList = (List<Integer>)staticCache.load(cacheKey, 100);
     902      List<Integer> posList = staticCache.load(cacheKey, 100);
    904903      if (posList == null)
    905904      {
  • trunk/src/core/net/sf/basedb/core/Annotation.java

    r7461 r7610  
    593593    @throws BaseException If there is an error
    594594  */
    595   public List<?> getValues()
     595  public <T> List<T> getValues()
    596596    throws BaseException
    597597  {
    598598    if (getSource() == Source.INHERITED) return Collections.emptyList();
    599     List<?> values = Values.getItemValues(getDbControl(), getData().getValues().getValues());
     599    List<T> values = Values.getItemValues(getDbControl(), getData().getValues().getValues());
    600600    return Collections.unmodifiableList(values);
    601601  }
     
    613613    @since 2.9
    614614  */
    615   public List<?> getValues(Unit unit)
     615  @SuppressWarnings("unchecked")
     616  public <T> List<T> getValues(Unit unit)
    616617    throws BaseException
    617618  {
    618619    if (getSource() == Source.INHERITED) return Collections.emptyList();
    619     List<?> values = Values.getItemValues(getDbControl(), getData().getValues().getValues());
     620    List<T> values = Values.getItemValues(getDbControl(), getData().getValues().getValues());
    620621    UnitConverter converter = getUnitConverter(unit);
    621622    if (converter != null)
    622623    {
    623       List<Object> convertedValues = new ArrayList<Object>(values.size());
     624      List<T> convertedValues = new ArrayList<>(values.size());
    624625      Type valueType = getValueType();
    625       for (Object value : values)
     626      for (T value : values)
    626627      {
    627628        if (value instanceof Number)
    628629        {
    629           value = valueType.convertNumber(converter.convertToSpecificUnit(((Number)value).doubleValue()));
     630          value = (T)valueType.convertNumber(converter.convertToSpecificUnit(((Number)value).doubleValue()));
    630631        }
    631632        convertedValues.add(value);
  • trunk/src/core/net/sf/basedb/core/AnnotationSet.java

    r7381 r7610  
    475475        getData().setItemId(itemId);
    476476      }
    477       item = (Annotatable)getItemType().getById(dc, itemId);     
     477      item = getItemType().getById(dc, itemId);     
    478478    }
    479479    else if (dc != null)
    480480    {
    481       item = (Annotatable)getItemType().getById(dc, item.getId());
     481      item = getItemType().getById(dc, item.getId());
    482482    }
    483483    return item;
  • trunk/src/core/net/sf/basedb/core/AnnotationType.java

    r7381 r7610  
    12061206    @throws BaseException If there is an error
    12071207  */
    1208   public List<?> getValues()
     1208  public <T> List<T> getValues()
    12091209    throws BaseException
    12101210  {
  • trunk/src/core/net/sf/basedb/core/DbControl.java

    r7605 r7610  
    974974        {
    975975          constructorParams = new Object[1];
    976           c = (Constructor<? extends I>)itemType.getConstructor();
     976          c = itemType.getConstructor();
    977977        }
    978978        constructorParams[0] = data;       
  • trunk/src/core/net/sf/basedb/core/Item.java

    r7511 r7610  
    827827    @throws BaseException If there is another error
    828828  */
    829   public BasicItem getById(DbControl dc, int id)
     829  @SuppressWarnings("unchecked")
     830  public <T extends BasicItem> T getById(DbControl dc, int id)
    830831    throws ItemNotFoundException, PermissionDeniedException, BaseException
    831832  {
     
    838839      try
    839840      {
    840         return (BasicItem)getById.invoke(null, dc, id);
     841        return (T)getById.invoke(null, dc, id);
    841842      }
    842843      catch (Throwable ex)
     
    876877  */
    877878  @SuppressWarnings("unchecked")
    878   public ItemQuery<? extends BasicItem> getQuery()
     879  public <T extends BasicItem> ItemQuery<T> getQuery()
    879880  {
    880881    if (getQuery == null)
     
    886887      try
    887888      {
    888         return (ItemQuery<? extends BasicItem>)getQuery.invoke(null);
     889        return (ItemQuery<T>)getQuery.invoke(null);
    889890      }
    890891      catch (Throwable ex)
     
    915916    @see DbControl#getItem(Class, BasicData, Object[])
    916917  */
    917   Constructor<? extends BasicItem> getConstructor()
    918   {
    919     return constructor;
     918  @SuppressWarnings("unchecked")
     919  <T extends BasicItem> Constructor<T> getConstructor()
     920  {
     921    return (Constructor<T>)constructor;
    920922  }
    921923
  • trunk/src/core/net/sf/basedb/core/ItemContext.java

    r7605 r7610  
    11701170  }
    11711171 
    1172   @SuppressWarnings("unchecked")
    11731172  private <T extends BasicItem> List<T> loadRecent(DbControl dc, Item itemType, String key)
    11741173  {
     
    11791178      try
    11801179      {
    1181         recent.add((T)itemType.getById(dc, Integer.parseInt(id)));
     1180        recent.add(itemType.getById(dc, Integer.parseInt(id)));
    11821181      }
    11831182      catch (Throwable t)
  • trunk/src/core/net/sf/basedb/core/ItemList.java

    r7599 r7610  
    676676    @see Item#getQuery()
    677677  */
    678   @SuppressWarnings("unchecked")
    679678  public ItemQuery<? extends Listable> getAllItems()
    680679    throws BaseException
    681680  {
    682     return (ItemQuery<? extends Listable>)getMemberType().getQuery();
     681    return getMemberType().getQuery();
    683682  }
    684683
  • trunk/src/core/net/sf/basedb/core/Values.java

    r5384 r7610  
    6161    @throws BaseException If there is another error
    6262  */
    63   static Object getItemValue(DbControl dc, Object value)
     63  @SuppressWarnings("unchecked")
     64  static <T> T getItemValue(DbControl dc, Object value)
    6465    throws PermissionDeniedException, BaseException
    6566  {
     
    7980      }
    8081    }
    81     return value;
     82    return (T)value;
    8283  }
    8384
     
    8687    @see #getItemValue(DbControl, Object)
    8788  */
    88   static List<Object> getItemValues(DbControl dc, List<?> dataValues)
     89  static <T> List<T> getItemValues(DbControl dc, List<?> dataValues)
    8990    throws PermissionDeniedException, ItemNotFoundException, BaseException
    9091  {
     
    9293    try
    9394    {
    94       List<Object> itemValues = new ArrayList<Object>(dataValues.size());
     95      List<T> itemValues = new ArrayList<>(dataValues.size());
    9596      for (int i = 0; i < dataValues.size(); i++)
    9697      {
     
    114115    @param value The value to convert
    115116  */
    116   static Object getDataValue(Object value)
     117  @SuppressWarnings("unchecked")
     118  static <T> T getDataValue(Object value)
    117119  {
    118120    if (value instanceof Date)
     
    124126      value = ((BasicItem)value).getData();
    125127    }
    126     return value;
     128    return (T)value;
    127129  }
    128130 
     
    131133    @see #getDataValue(Object)
    132134  */
    133   static List<Object> getDataValues(List<?> itemValues)
     135  static <T> List<T> getDataValues(List<?> itemValues)
    134136  {
    135137    if (itemValues == null) return null;
    136     List<Object> dataValues = new ArrayList<Object>(itemValues.size());
     138    List<T> dataValues = new ArrayList<>(itemValues.size());
    137139    for (int i = 0; i < itemValues.size(); i++)
    138140    {
  • trunk/src/core/net/sf/basedb/core/snapshot/AnnotationSetSnapshot.java

    r7250 r7610  
    147147  public Annotatable getItem(DbControl dc)
    148148  {
    149     return (Annotatable)itemType.getById(dc, itemId);
     149    return itemType.getById(dc, itemId);
    150150  }
    151151 
  • trunk/src/core/net/sf/basedb/core/snapshot/AnnotationSnapshot.java

    r7250 r7610  
    467467    @return A list with the values or null
    468468  */
    469   public List<? extends Serializable> getThisValues()
    470   {
    471     return values;
     469  @SuppressWarnings("unchecked")
     470  public <T extends Serializable> List<T> getThisValues()
     471  {
     472    return (List<T>)values;
    472473  }
    473474 
     
    478479    @since 3.6
    479480  */
    480   public List<? extends Serializable> getActualValues()
    481   {
    482     return inheritedFrom != null && values == null ? inheritedFrom.values : values;
     481  @SuppressWarnings("unchecked")
     482  public <T extends Serializable> List<T> getActualValues()
     483  {
     484    return (List<T>)(inheritedFrom != null && values == null ? inheritedFrom.values : values);
    483485  }
    484486 
     
    501503  */
    502504  @Deprecated
    503   public List<? extends Serializable> getValues(UnitConverter converter, Type valueType)
     505  public <T extends Serializable> List<T> getValues(UnitConverter converter, Type valueType)
    504506  {
    505507    return getActualValues(converter, valueType);
     
    522524    @since 3.6
    523525  */
    524   public List<? extends Serializable> getActualValues(UnitConverter converter, Type valueType)
    525   {
    526     List<? extends Serializable> vals = getActualValues();
     526  @SuppressWarnings("unchecked")
     527  public <T extends Serializable> List<T> getActualValues(UnitConverter converter, Type valueType)
     528  {
     529    List<T> vals = getActualValues();
    527530    if (converter == null) return vals;
    528     List<Serializable> convertedValues = new ArrayList<Serializable>(vals.size());
    529     for (Serializable value : vals)
     531    List<T> convertedValues = new ArrayList<>(vals.size());
     532    for (T value : vals)
    530533    {
    531534      if (value instanceof Number)
    532535      {
    533         value = valueType.convertNumber(converter.convertToSpecificUnit(((Number)value).doubleValue()));
     536        value = (T)valueType.convertNumber(converter.convertToSpecificUnit(((Number)value).doubleValue()));
    534537      }
    535538      convertedValues.add(value);
     
    597600  public Annotatable getItem(DbControl dc)
    598601  {
    599     return getItemId() == 0 ? null : (Annotatable)getItemType().getById(dc, getItemId());
     602    return getItemId() == 0 ? null : getItemType().getById(dc, getItemId());
    600603  }
    601604
     
    607610  public Annotatable getThisItem(DbControl dc)
    608611  {
    609     return itemId == 0 ? null : (Annotatable)itemType.getById(dc, itemId);
     612    return itemId == 0 ? null : itemType.getById(dc, itemId);
    610613  }
    611614 
  • trunk/src/core/net/sf/basedb/core/snapshot/SnapshotManager.java

    r7299 r7610  
    171171    StaticCache cache = Application.getStaticCache();
    172172    String cacheKey = getCacheKey(annotationSetId);
    173     snapshot = (AnnotationSetSnapshot)cache.load(cacheKey, 1000);
     173    snapshot = cache.load(cacheKey, 1000);
    174174    if (snapshot == null)
    175175    {
  • trunk/src/core/net/sf/basedb/util/OwnableUtil.java

    r4587 r7610  
    6060      if (id != null)
    6161      {
    62         Ownable item = (Ownable)itemType.getById(dc, id);
     62        Ownable item = itemType.getById(dc, id);
    6363        if (item.hasPermission(Permission.SET_OWNER))
    6464        {
     
    8888      if (ownedItem != null)
    8989      {
    90         Ownable item = (Ownable)ownedItem.getType().getById(dc, ownedItem.getId());
     90        Ownable item = ownedItem.getType().getById(dc, ownedItem.getId());
    9191        if (item.hasPermission(Permission.SET_OWNER))
    9292        {
  • trunk/src/core/net/sf/basedb/util/RemovableUtil.java

    r5020 r7610  
    6161      if (id != null)
    6262      {
    63         Removable item = (Removable)itemType.getById(dc, id);
     63        Removable item = itemType.getById(dc, id);
    6464        if (item.isRemoved() != removed)
    6565        {
     
    100100      if (id != null)
    101101      {       
    102         Removable item = (Removable)itemType.getById(dc, id);
     102        Removable item = itemType.getById(dc, id);
    103103        numHandled = removeDependingItems(dc, item, removed);
    104104        if ((item instanceof Directory || item instanceof File) && !removed)
  • trunk/src/core/net/sf/basedb/util/ShareableUtil.java

    r4889 r7610  
    6060      if (id != null)
    6161      {
    62         SharedItem item = (SharedItem)itemType.getById(dc, id);
     62        SharedItem item = itemType.getById(dc, id);
    6363        if (item.hasPermission(Permission.SET_PERMISSION))
    6464        {
  • trunk/src/core/net/sf/basedb/util/StaticCache.java

    r7352 r7610  
    407407      exists or if a read lock couldn't be aquired
    408408  */
    409   public Object load(String key, int timeout)
     409  public <T> T load(String key, int timeout)
    410410  {
    411411    return load(key, null, timeout);
    412412  }
    413413 
    414   public Object load(String key, ClassLoader loader, int timeout)
     414  @SuppressWarnings("unchecked")
     415  public <T> T load(String key, ClassLoader loader, int timeout)
    415416  {
    416417    if (disabled) return null;
     
    469470      }
    470471    }
    471     return object;   
     472    return (T)object;   
    472473   
    473474  }
  • trunk/src/core/net/sf/basedb/util/annotations/RunnableInheritAnnotationsManager.java

    r6909 r7610  
    118118        ThreadSignalHandler.checkInterrupted();
    119119        // Reload item in current transaction
    120         item = (Annotatable)item.getType().getById(dc, item.getId());
     120        item = item.getType().getById(dc, item.getId());
    121121
    122122        itemName = item instanceof Nameable ? ((Nameable)item).getName() : item.toString();
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/FallbackIdMethod.java

    r7101 r7610  
    139139    load the item.
    140140  */
    141   @SuppressWarnings("unchecked")
    142141  @Override
    143142  public <I extends BasicItem> List<I> find(DbControl dc, ItemQuery<I> query, String identifier)
     
    151150        try
    152151        {
    153           I item = (I)query.getItemType().getById(dc, id);
     152          I item = query.getItemType().getById(dc, id);
    154153          items = Collections.singletonList(item);
    155154        }
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/InternalIdMethod.java

    r4513 r7610  
    102102    used except to find the type of item to load.
    103103  */
    104   @SuppressWarnings("unchecked")
    105104  @Override
    106105  public <I extends BasicItem> List<I> find(DbControl dc, ItemQuery<I> query, String identifier)
     
    112111      try
    113112      {
    114         I item = (I)query.getItemType().getById(dc, id);
     113        I item = query.getItemType().getById(dc, id);
    115114        items.add(item);
    116115      }
  • trunk/src/test/net/sf/basedb/test/roles/UserTest.java

    r6958 r7610  
    717717    for (Annotatable parent : parents)
    718718    {
    719       parent = (Annotatable)parent.getType().getById(dc, parent.getId());
     719      parent = parent.getType().getById(dc, parent.getId());
    720720      if (parent.isAnnotated())
    721721      {
  • trunk/www/admin/annotationtypes/edit_annotationtype.jsp

    r7604 r7610  
    644644            <%
    645645            String values = annotationType == null ? "" :
    646               Values.getString((List<Date>)annotationType.getValues(), "\n", true, dateFormatter);
     646              Values.getString(annotationType.getValues(), "\n", true, dateFormatter);
    647647            %>
    648648            <textarea class="text" rows="10" name="values" id="values"
Note: See TracChangeset for help on using the changeset viewer.