Example usage for java.util ArrayList isEmpty

List of usage examples for java.util ArrayList isEmpty

Introduction

In this page you can find the example usage for java.util ArrayList isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:com.daveoxley.cbus.Response.java

public void handle200() throws CGateException {
    ArrayList<String> resp_array = toArray();
    if (resp_array.isEmpty())
        throw new CGateException();

    String resp_str = resp_array.get(resp_array.size() - 1);
    String result_code = resp_str.substring(0, 3).trim();
    if (!result_code.equals("200"))
        throw new CGateException(resp_str);
}

From source file:com.appglu.impl.CrudTemplate.java

private Object extractPrimaryKeyValue(Row primaryKey) {
    ArrayList<String> keySet = new ArrayList<String>(primaryKey.keySet());

    if (keySet.isEmpty()) {
        return null;
    }//  w w w.  ja va 2 s  .c  om

    return primaryKey.get(keySet.get(0));
}

From source file:com.jerrellmardis.amphitheatre.task.GetFilesTask.java

@Override
protected List<SmbFile> doInBackground(Void... params) {
    mConfig = ApiClient.getInstance().createTMDbClient().getConfig();
    ArrayList<SmbFile> myFiles = new ArrayList<SmbFile>(DownloadTaskHelper.getFiles(mUser, mPassword, mPath));
    if (myFiles.isEmpty()) {
        Handler h = new Handler(Looper.getMainLooper()) {
            @Override//from w  w  w  . ja  v a 2 s. c  o  m
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                Toast.makeText(mContext,
                        "Cannot find any files. Make sure your authentication information is correct.",
                        Toast.LENGTH_SHORT).show();
            }
        };
        h.sendEmptyMessage(0);
        return new ArrayList<SmbFile>(); //Return empty set
    } else {
        return myFiles;
    }
}

From source file:com.onpositive.semantic.wikipedia.abstracts.svc.HtmlRendererBase.java

private void printPart(String format, ArrayList<Object> a, int last, int i) {
    if (i - last > 0) {
        String f = format.substring(last, i);
        if (a.isEmpty()) {
            p.print(f);/*ww  w.j  a v  a  2  s .  co  m*/
        } else {
            p.print(String.format(f, a.toArray()));
            a.clear();
        }
    }
}

From source file:com.perl5.lang.perl.util.PerlPackageUtil.java

/**
 * Make canonical package name.//from   w  w  w .  ja v  a2  s . c  o  m
 *
 * @param name package name
 * @return canonical package name
 */
public static String getCanonicalPackageName(String name) {
    String newName;

    if ((newName = CANONICAL_NAMES_CACHE.get(name)) != null) {
        return newName;
    }

    String originalName = name;

    //      System.out.println("Source: " + name);
    // removing trailing separator if any
    name = PACKAGE_SEPARATOR_TAIL_RE.matcher(name).replaceFirst("");
    //      System.out.println("Notail: " + name);

    ArrayList<String> canonicalChunks = new ArrayList<String>();
    String[] chunks = PACKAGE_SEPARATOR_RE.split(name, -1);

    //      System.out.println("Chunks: " + chunks.length);

    if (chunks.length > 0 && chunks[0].isEmpty()) // implicit main
    {
        chunks[0] = PerlPackageUtil.MAIN_PACKAGE;
    }

    for (String chunk : chunks) {
        if (!(canonicalChunks.isEmpty() && chunk.equals("main"))) {
            canonicalChunks.add(chunk);
        }
    }

    //      System.out.println("Canonical chunks: " + chunks.length);

    if (canonicalChunks.isEmpty()) {
        newName = "main";
    } else {
        newName = StringUtils.join(canonicalChunks, "::");
    }

    //      System.out.println("Canonical: " + newName + "\n");
    CANONICAL_NAMES_CACHE.put(originalName, newName);

    return newName;
}

From source file:edu.lafayette.metadb.web.metadata.PrintMetadata.java

protected String getTemplate(String projname, int index) {
    StringBuilder template = new StringBuilder();

    template.append("<div style='width:95%'>");
    template.append("<table align='left' cellpadding='10' style='width:100%'>");
    template.append("<tbody>");
    template.append("<tr valign='top'>");
    template.append("<td id='image-holder' width='310px' align='center' style='width:310px'>");

    String thumbPath = ItemsDAO.getThumbFilePath(projname, index);
    String thumbName = new File(thumbPath).getName();
    String thumbFilePath = Global.PATH_PROJECT + projname + "/" + thumbName;
    template.append("<img style='max-width: 300px; max-height: 300px;' src='" + thumbFilePath + "'>");

    template.append("</td>");
    template.append("<td align='center'>");
    template.append("<p><span style='font-weight: bold;'>Project</span>:<br/>" + projname + "</p>");
    template.append("<p><span style='font-weight: bold;'>Item Number</span>:<br/>" + index + "</p>");
    template.append("<p><span style='font-weight: bold;'>Filename</span>:<br/>"
            + ShowImageMetadata.getItemInfo(projname, index) + "</p>");
    template.append("</td>");
    template.append("</tr>");
    template.append("</tbody>");
    template.append("</table>");
    template.append("</div><br/>");
    template.append("<div style='width:95%; margin-top:310px'>");

    Item item = ItemsDAO.getItem(projname, index);

    ArrayList<AdminDescItem> mdList = item.getData(Global.MD_TYPE_DESC);
    if (!mdList.isEmpty()) {
        template.append("<div><h3 style='text-decoration: underline;'>Descriptive Metadata</h3>");
        for (AdminDescItem m : mdList)
            template.append(this.getMetadataDisplay(m.getMetadata()));
        template.append("</div>");
    }//w  ww.jav  a 2s .  co  m

    mdList = item.getData(Global.MD_TYPE_ADMIN);
    if (!mdList.isEmpty()) {
        template.append("<div><h3 style='text-decoration: underline;'>Administrative Metadata</h3>");
        for (AdminDescItem m : mdList)
            template.append(this.getMetadataDisplay(m.getMetadata()));
        template.append("</div>");
    }

    template.append("<div><h3 style='text-decoration: underline;'>Technical Metadata</h3>");
    List<Metadata> techMD = ItemsDAO.getTechData(projname, index);
    for (Metadata m : techMD)
        template.append(this.getMetadataDisplay(m));
    template.append("</div>");

    template.append("</div>");
    return template.toString();
}

From source file:info.archinnov.achilles.entity.parsing.validator.EntityParsingValidator.java

public void validatePropertyMetas(EntityParsingContext context, PropertyMeta idMeta) {
    log.debug("Validate that there is at least one property meta for the entity class {}",
            context.getCurrentEntityClass().getCanonicalName());

    ArrayList<PropertyMeta> metas = new ArrayList<PropertyMeta>(context.getPropertyMetas().values());
    metas.remove(idMeta);//from ww w.  j  av  a  2  s .co m
    Validator.validateBeanMappingFalse(metas.isEmpty(), "The entity '"
            + context.getCurrentEntityClass().getCanonicalName()
            + "' should have at least one field with javax.persistence.Column/javax.persistence.Id/javax.persistence.EmbeddedId annotations");

}

From source file:org.khmeracademy.btb.auc.pojo.controller.Product_owner_controller.java

@RequestMapping(value = "/get", method = RequestMethod.GET, produces = "application/json")
@ResponseBody// w  w w. j  ava 2  s . co m
public ResponseEntity<Map<String, Object>> getUsers() {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
        ArrayList<Product_Owner> users = pro_owner_service.get_Product_Owner();
        if (!users.isEmpty()) {
            map.put("DATA", users);
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA FOUND!");
        } else {
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA NOT FOUND");
        }
    } catch (Exception e) {
        map.put("STATUS", false);
        map.put("MESSAGE", "Error!");
        e.printStackTrace();
    }
    return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK);
}

From source file:org.mythtv.service.guide.v25.ProgramGuideHelperV25.java

private static int load(final Context context, final LocationProfile locationProfile,
        final ProgramGuide programGuide) throws RemoteException, OperationApplicationException {
    Log.d(TAG, "load : enter");

    if (null == context)
        throw new RuntimeException("ProgramGuideHelperV25 is not initialized");

    String tag = UUID.randomUUID().toString();
    int processed = -1;
    int count = 0;

    ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();

    for (ChannelInfo channel : programGuide.getChannels()) {

        for (Program program : channel.getPrograms()) {
            //Log.i( TAG, "load : count=" + count );

            program.setChannel(channel);
            program.setHostName(locationProfile.getHostname());

            ProgramHelperV25.getInstance().processProgram(context, locationProfile,
                    ProgramConstants.CONTENT_URI_GUIDE, ProgramConstants.TABLE_NAME_GUIDE, ops, program, tag);
            count++;/*  www . j a v  a2  s  . c o m*/

            if (count > BATCH_COUNT_LIMIT) {
                //               Log.i( TAG, "load : applying batch for '" + count + "' transactions, processing programs" );

                processBatch(context, ops, processed, count);

                count = 0;
            }

        }

    }

    if (!ops.isEmpty()) {
        //         Log.i( TAG, "load : applying final batch for '" + count + "' transactions, processing programs" );

        processBatch(context, ops, processed, count);
    }

    //      Log.v( TAG, "load : exit" );
    return processed;
}

From source file:org.mythtv.service.guide.v26.ProgramGuideHelperV26.java

private static int load(final Context context, final LocationProfile locationProfile,
        final ProgramGuide programGuide) throws RemoteException, OperationApplicationException {
    Log.d(TAG, "load : enter");

    if (null == context)
        throw new RuntimeException("ProgramGuideHelperV26 is not initialized");

    String tag = UUID.randomUUID().toString();
    int processed = -1;
    int count = 0;

    ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();

    for (ChannelInfo channel : programGuide.getChannels()) {

        for (Program program : channel.getPrograms()) {
            //Log.i( TAG, "load : count=" + count );

            program.setChannel(channel);
            program.setHostName(locationProfile.getHostname());

            ProgramHelperV26.getInstance().processProgram(context, locationProfile,
                    ProgramConstants.CONTENT_URI_GUIDE, ProgramConstants.TABLE_NAME_GUIDE, ops, program, tag);
            count++;//w  ww . ja  va  2s  .com

            if (count > BATCH_COUNT_LIMIT) {
                //               Log.i( TAG, "load : applying batch for '" + count + "' transactions, processing programs" );

                processBatch(context, ops, processed, count);

                count = 0;
            }

        }

    }

    if (!ops.isEmpty()) {
        //         Log.i( TAG, "load : applying final batch for '" + count + "' transactions, processing programs" );

        processBatch(context, ops, processed, count);
    }

    //      Log.v( TAG, "load : exit" );
    return processed;
}