Skip to content

Commit bc4603e

Browse files
committed
Added functionality for liststreamitems, which is like liststreamkeyitems, but it doesn't require a key to be specified, which is handy for us. I've tested it (insofar as I've used it) and it works. I tried to match your code style, so hopefully it's ok. Also added *.iml to .gitignore (settings files created by IntelliJ IDEA)
1 parent 6314e72 commit bc4603e

File tree

3 files changed

+195
-0
lines changed

3 files changed

+195
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ hs_err_pid*
1616
/.gitignore
1717
/target
1818
/.settings
19+
*.iml

src/main/java/multichain/command/StreamCommand.java

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,137 @@ public List<StreamKeyItem> listStreamKeyItems(String streamName, String key) thr
507507
return listStreamKeyItems(streamName, key, false, 10);
508508
}
509509

510+
/**
511+
* liststreamkeyitems "stream-identifier" ( verbose count start
512+
* local-ordering )
513+
*
514+
* Returns stream items.
515+
*
516+
* Arguments: 1. "stream-identifier"(string, required) Stream identifier - one
517+
* of the following: stream txid, stream reference, stream name. 2. verbose (boolean, optional, default=false)
518+
* If true, returns information about item transaction 3. count (number,
519+
* optional, default=10) The number of items to display 4. start (number,
520+
* optional, default=-count - last) Start from specific item, 0 based, if
521+
* negative - from the end 5. local-ordering (boolean, optional, default=false)
522+
* If true, items appear in the order they were processed by the wallet, if
523+
* false - in the order they appear in blockchain
524+
*
525+
* Result: "stream-items" (array) List of stream items.
526+
*
527+
* @param streamName
528+
* @param verbose
529+
* @param count
530+
* @param start
531+
* @return
532+
* @throws MultichainException
533+
*/
534+
@SuppressWarnings("unchecked")
535+
public List<StreamKeyItem> listStreamItems(String streamName, boolean verbose, int count, int start)
536+
throws MultichainException {
537+
List<StreamKeyItem> streamKeyItems = new ArrayList<StreamKeyItem>();
538+
539+
Object objectStreamKeyItems = executeListStreamItems(streamName, verbose, count, start);
540+
if (verifyInstance(objectStreamKeyItems, ArrayList.class)
541+
&& verifyInstanceofList((ArrayList<Object>) objectStreamKeyItems, StreamKeyItem.class)) {
542+
streamKeyItems = StreamFormatter.formatStreamKeyItems((ArrayList<Object>) objectStreamKeyItems);
543+
}
544+
545+
return streamKeyItems;
546+
}
547+
548+
/**
549+
* liststreamkeyitems "stream-identifier" ( verbose count start
550+
* local-ordering )
551+
*
552+
* Returns stream items.
553+
*
554+
* Arguments: 1. "stream-identifier"(string, required) Stream identifier - one
555+
* of the following: stream txid, stream reference, stream name. 2. verbose (boolean, optional, default=false)
556+
* If true, returns information about item transaction 3. count (number,
557+
* optional, default=10) The number of items to display 4. start (number,
558+
* optional, default=-count - last) Start from specific item, 0 based, if
559+
* negative - from the end 5. local-ordering (boolean, optional, default=false)
560+
* If true, items appear in the order they were processed by the wallet, if
561+
* false - in the order they appear in blockchain
562+
*
563+
* Result: "stream-items" (array) List of stream items.
564+
*
565+
* @param streamName
566+
* @param verbose
567+
* @param count
568+
* * @return
569+
* @throws MultichainException
570+
*/
571+
@SuppressWarnings("unchecked")
572+
public List<StreamKeyItem> listStreamItems(String streamName, boolean verbose, int count)
573+
throws MultichainException {
574+
List<StreamKeyItem> streamKeyItems = new ArrayList<StreamKeyItem>();
575+
576+
Object objectStreamKeyItems = executeListStreamItems(streamName, verbose, count);
577+
if (verifyInstance(objectStreamKeyItems, ArrayList.class)
578+
&& verifyInstanceofList((ArrayList<Object>) objectStreamKeyItems, StreamKeyItem.class)) {
579+
streamKeyItems = StreamFormatter.formatStreamKeyItems((ArrayList<Object>) objectStreamKeyItems);
580+
}
581+
582+
return streamKeyItems;
583+
}
584+
585+
/**
586+
* liststreamkeyitems "stream-identifier" ( verbose count start
587+
* local-ordering )
588+
*
589+
* Returns stream items.
590+
*
591+
* Arguments: 1. "stream-identifier"(string, required) Stream identifier - one
592+
* of the following: stream txid, stream reference, stream name. 2. verbose (boolean, optional, default=false)
593+
* If true, returns information about item transaction 3. count (number,
594+
* optional, default=10) The number of items to display 4. start (number,
595+
* optional, default=-count - last) Start from specific item, 0 based, if
596+
* negative - from the end 5. local-ordering (boolean, optional, default=false)
597+
* If true, items appear in the order they were processed by the wallet, if
598+
* false - in the order they appear in blockchain
599+
*
600+
* Result: "stream-items" (array) List of stream items.
601+
*
602+
* @param streamName
603+
* @param verbose
604+
* @param count
605+
* = 10 * @return
606+
* @throws MultichainException
607+
*/
608+
public List<StreamKeyItem> listStreamItems(String streamName, boolean verbose)
609+
throws MultichainException {
610+
return listStreamItems(streamName, verbose, 10);
611+
}
612+
613+
/**
614+
* liststreamkeyitems "stream-identifier" ( verbose count start
615+
* local-ordering )
616+
*
617+
* Returns stream items.
618+
*
619+
* Arguments: 1. "stream-identifier"(string, required) Stream identifier - one
620+
* of the following: stream txid, stream reference, stream name. 2. verbose (boolean, optional, default=false)
621+
* If true, returns information about item transaction 3. count (number,
622+
* optional, default=10) The number of items to display 4. start (number,
623+
* optional, default=-count - last) Start from specific item, 0 based, if
624+
* negative - from the end 5. local-ordering (boolean, optional, default=false)
625+
* If true, items appear in the order they were processed by the wallet, if
626+
* false - in the order they appear in blockchain
627+
*
628+
* Result: "stream-items" (array) List of stream items.
629+
*
630+
* @param streamName
631+
* @param verbose
632+
* = false
633+
* @param count
634+
* = 10 * @return
635+
* @throws MultichainException
636+
*/
637+
public List<StreamKeyItem> listStreamItems(String streamName) throws MultichainException {
638+
return listStreamItems(streamName, false, 10);
639+
}
640+
510641
/**
511642
* publish "stream-identifier" "key" data-hex
512643
*

src/main/java/multichain/command/builders/QueryBuilderStream.java

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,69 @@ protected Object executeListStreamKeyItems(String streamName, String key, boolea
243243
return execute(CommandEnum.LISTSTREAMKEYITEMS, streamName, key, verbose, count);
244244
}
245245

246+
/**
247+
* liststreamitems "stream-identifier" ( verbose count start
248+
* local-ordering )
249+
*
250+
* Returns stream items.
251+
*
252+
* Arguments: 1. "stream-identifier"(string, required) Stream identifier - one
253+
* of the following: stream txid, stream reference, stream name. 2. verbose (boolean, optional, default=false)
254+
* If true, returns information about item transaction 3. count (number,
255+
* optional, default=10) The number of items to display 4. start (number,
256+
* optional, default=-count - last) Start from specific item, 0 based, if
257+
* negative - from the end 5. local-ordering (boolean, optional, default=false)
258+
* If true, items appear in the order they were processed by the wallet, if
259+
* false - in the order they appear in blockchain
260+
*
261+
* Result: "stream-items" (array) List of stream items for specific key.
262+
*
263+
* @param streamName
264+
* @param verbose
265+
* @param count
266+
* @param start
267+
* @return
268+
* @throws MultichainException
269+
*/
270+
protected Object executeListStreamItems(String streamName, boolean verbose, int count, int start)
271+
throws MultichainException {
272+
MultichainTestParameter.isNotNullOrEmpty("streamName", streamName);
273+
MultichainTestParameter.valueIsPositive("count", count);
274+
275+
return execute(CommandEnum.LISTSTREAMITEMS, streamName, verbose, count, start);
276+
}
277+
278+
/**
279+
* liststreamitems "stream-identifier" ( verbose count start
280+
* local-ordering )
281+
*
282+
* Returns stream items.
283+
*
284+
* Arguments: 1. "stream-identifier"(string, required) Stream identifier - one
285+
* of the following: stream txid, stream reference, stream name. 2. verbose (boolean, optional, default=false)
286+
* If true, returns information about item transaction 3. count (number,
287+
* optional, default=10) The number of items to display 4. start (number,
288+
* optional, default=-count - last) Start from specific item, 0 based, if
289+
* negative - from the end 5. local-ordering (boolean, optional, default=false)
290+
* If true, items appear in the order they were processed by the wallet, if
291+
* false - in the order they appear in blockchain
292+
*
293+
* Result: "stream-items" (array) List of stream items for specific key.
294+
*
295+
* @param streamName
296+
* @param verbose
297+
* @param count
298+
* @return
299+
* @throws MultichainException
300+
*/
301+
protected Object executeListStreamItems(String streamName, boolean verbose, int count)
302+
throws MultichainException {
303+
MultichainTestParameter.isNotNullOrEmpty("streamName", streamName);
304+
MultichainTestParameter.valueIsPositive("count", count);
305+
306+
return execute(CommandEnum.LISTSTREAMITEMS, streamName, verbose, count);
307+
}
308+
246309
/**
247310
* publish "stream-identifier" "key" data-hex
248311
*

0 commit comments

Comments
 (0)